随笔分类 -  JDBC

[JDBC]ORA-01000: 超出打开游标的最大数(ORA-01000: maximum open cursors exceeded)
摘要:问题产生的原因: Java代码在执行conn.createStatement()和conn.prepareStatement()的时候,相当于在数据库中打开了一个cursor。由于oracle对打开的游标的数量做了限制,如果你的createStatement和prepareStatement是在一个循环里面,并且没有及时关闭的话,就会非常容易出现这个问题。 所以,“超出打开游标的最大数”这个异常通常是由于我们没有及时关闭statement造成的。因此,我们在写Java代码的时候,createStatement和prepareStatement都应该要放在循环外面,并且一定要及时关闭。 查... 阅读全文

posted @ 2013-08-02 10:43 LoveEyes 阅读(3804) 评论(0) 推荐(0)

[JDBC]你真的会正确关闭connection吗?
摘要:Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; try { conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/test","root","fendou"); stmt = conn.prepareStatement("select 1 from dual"); rs = stmt.executeQuery(); while(rs.next()){ 阅读全文

posted @ 2013-07-18 01:04 LoveEyes 阅读(10192) 评论(2) 推荐(1)

导航