java.sql.SQLException: ORA-01000: maximum open cursors exceeded
Oracle Java About 985 words错误信息
java.sql.SQLException: ORA-01000: maximum open cursors exceeded
原因
已经达到一个进程打开的最大游标数
long currentId = 1;
long maxId = 100;
long step = 2;
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@//127.0.0.1:1521/orcl";
conn = DriverManager.getConnection(url, "username", "password");
String sql = "DELETE FROM SEND_INFO WHERE ID < ?";
while (currentId <= maxDelId) {
conn.setAutoCommit(false);
PreparedStatement preparedStatement = conn.prepareStatement(sql);
preparedStatement.setLong(1, currentId);
preparedStatement.execute();
conn.commit();
currentId += step;
}
} catch (Exception e) {
e.printStackTrace();
}
修改
PreparedStatement执行后关闭
preparedStatement.close();
PreparedStatement preparedStatement = conn.prepareStatement(sql);
preparedStatement.setLong(1, currentId);
preparedStatement.execute();
preparedStatement.close();
conn.commit();
Views: 3,016 · Posted: 2019-07-08
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...