Java-超出打开游标的最大数,求助关于:ORA-01000: 超出打开游标的最大数

我编写了一段java程序,向oracle中批量插入数据。下面是其中一段代码,请大家帮我分析一下为什么一直抛出ORA-01000: 超出打开游标的最大数异常。

Connection con = null;

//Statement stmt =null;

PreparedStatement pstmt = null;

ResultSet rstm = null;

ResultSet rs = null;

String url = urlRoot + dbName;

try {

Class.forName(jdbcDriver);

DriverManager.registerDriver(new OracleDriver());

con = DriverManager.getConnection(url, user, password);

con.setAutoCommit(false);

while((s = in.readLine()) != null){

if(s.contains(">")){

if(s.contains("|") & s.contains("- "))

{

int begin = s.indexOf("|");

int end = s.lastIndexOf("- ");

proID = s.substring(0, begin).trim();

abstractFunction = s.substring((begin + 1), end).trim();

organism = s.substring((end + 1)).trim();

}

}

else {

sequense = s;

if(proID != "" & sequense != "" ){

try{

CLOB clob = null;

if(pstmt == null)

pstmt = con.prepareStatement("select proid from maliky_first.uniproswiss where proid = ?");

pstmt.setString(1, proID);

rstm = pstmt.executeQuery();

if (!rstm.next()){

pstmt.close();

pstmt = null;

pstmt = con.prepareStatement("INSERT INTO maliky_first.uniproswiss (proid,sequense,abstractfunction,organism) VALUES(?,empty_clob(),?,?)");

pstmt.setString(1,proID);

pstmt.setString(2,abstractFunction);

pstmt.setString(3,organism);

pstmt.executeUpdate();

pstmt.close();

pstmt = con.prepareStatement("select sequense from maliky_first.uniproswiss where proid= ? for update");

pstmt.setString(1,proID);

rs = pstmt.executeQuery();

if (rs.next()) clob = (CLOB) rs.getClob(1);

rs.close();

pstmt = con.prepareStatement("update maliky_first.uniproswiss set sequense=? where proid=?");

Writer out = clob.getCharacterOutputStream();

out.write(sequense);

out.close();

pstmt.setClob(1,clob);

pstmt.setString(2,proID);

pstmt.executeUpdate();

pstmt.close();

}

rstm.close();

pstmt.close();

}catch(SQLException e){

System.out.println(proID);

System.err.println(e.getMessage());

System.err.println(e.getLocalizedMessage());

}finally{

try

{

if (pstmt != null)

pstmt.close();

}

catch(Exception e) {}

try

{

if (rs != null)

rs.close();

}

catch(Exception e) {}

try

{

if (rstm != null)

rstm.close();

}

catch(Exception e) {}

pstmt = null;

rs = null;

rstm = null;

}

}

}

}

con.commit();

con.close();

} catch (ClassNotFoundException e) {

System.err.println(e.getMessage());

}catch(SQLException e){

System.err.println(e.getMessage());

}finally{

try

{

if (pstmt != null)

pstmt.close();

}

catch(Exception e) {}

try

{

if (con != null)

con.close();

}

catch (Exception e){}

try

{

if (rs != null)

rs.close();

}

catch(Exception e) {}

try

{

if (rstm != null)

rstm.close();

}

catch(Exception e) {}

}

}

人打赏

0人 点赞

主帖获得的天涯分:0

举报 |

楼主

|

楼主发言:1次 发图:0张 | 添加到话题 |

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值