package connect.orcale;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class linkTest2 {
public static void main(String[] args) throws SQLException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:orcl", "scott", "Admin518"); // "scott", "Admin518"分别为用户名和密码
for(int i=1 ;i<=299;i++){//i不可以大于或等等于300
stmt = conn.prepareStatement("insert into USERT values(id.nextval,'ctl')");
stmt.executeUpdate();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
finally
{
if(rs!= null) rs.close();
if(stmt!= null) stmt.close();
if(conn != null) conn.close();
}
}
}
/*当for'循环中的i>=300时会出现下面的错误
* java.sql.SQLException: ORA-00604: 递归 SQL 级别 1 出现错误
ORA-01000: 超出打开游标的最大数
ORA-00604: 递归 SQL 级别 1 出现错误
ORA-01000: 超出打开游标的最大数
ORA-01000: 超出打开游标的最大数
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3400)
at connect.orcale.linkTest2.main(linkTest2.java:21)
Exception in thread "main" java.sql.SQLException: ORA-02002: 写入审计线索时出错
ORA-00604: 递归 SQL 级别 1 出现错误
ORA-01000: 超出打开游标的最大数
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:283)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:278)
at oracle.jdbc.driver.T4C7Ocommoncall.receive(T4C7Ocommoncall.java:141)
at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:464)
at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:1184)
at connect.orcale.linkTest2.main(linkTest2.java:33)
* */
java 连接orcale (使用for循环,循环次数不可以超过299)一
最新推荐文章于 2024-04-13 19:04:53 发布