原创 java.sql.SQLException: ORA-01000: 超出打开游标的最大数的原因 和解决方案
旧一篇: 复杂数学公式的做法? 新一篇: 旧一篇 关于生成 PDF 里复杂数学公式的做法? 新一篇 关于 Ajax 返回 html 的解析问题 先看有问题的代码 查看复制到剪切板打印 1. import java.sql.Connection; 2. import java.sql.DriverManager; 3. import java.sql.SQLException; 4. import java.sql.Statement; 5. 6. public class Test { 7. 8. 9. 10. 11. 12. 13. public Connection getConnection() { String url = "jdbc:oracle:thin:@localhost:1521:ora9i"; String user = "scott"; String password = "tiger"; Connection con = null; try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. } }
con = DriverManager.getConnection(url, user, password); } catch (Exception e) { e.printStackTrace();
return con;
public static void main(String[] args) throws SQLException { long a = 138********L; long b = 138********L; // 问题点 Connection con = null; Statement stmt = null; Test insert = new Test(); try { con = insert.getConnection(); for (long c = a; c <= b; c++) { String sql = "insert into telepnum values(" + c + ")"; stmt = con.createStatement(); // 这里是问题的所在 stmt.executeUpdate(sql); } System.out.println("OK");