多用户并发执行insert语句,返回值该是多少! 可以用try catch机制,主键重复会有相应的exception 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 try { getDBConnection(); stmt = dbConnection.prepareStatement(queryStr); resultCount = stmt.executeUpdate(); System.out.println(" dbConnection = " + dbConnection); System.out.println(" stmt = " + stmt); if ( resultCount != 1 ){ System.out.println("queryString is: "+ queryStr); throw new OrderDAODBUpdateException("ERROR in ORDER_TABLE INSERT !! resultCount " + resultCount); }else { queryStr = "SELECT ordernum.currval from " + DatabaseNames.ORDER_TABLE; ResultSet rs = stmt.executeQuery(queryStr); if ( !rs.next() ) { throw new OrderDAOAppException("ERROR in selecting OrderId !!"); } else { oid = rs.getInt(1); if (oid < 1) throw new OrderDAOAppException("ERROR in getting OrderId !! orderId = "+ oid); } } // end else } catch(SQLException se) { se.printStackTrace(); throw new OrderDAOSysException("SQLException occured in insertOrder"); } finally { try { if(stmt != null) stmt.close(); closeConnection(); } catch(SQLException se) { throw new OrderDAOSysException("SQLException while closing statement and connection"); } } // end finally oracle表分区问题 做过数据库表分区的高手请进,非常感谢 高分求解,在win2003调用ORACLE存储过程权限不足问题 [高分求救]oracle analytic workspace java API的问题!! 不同类型文件插入数据库 关于LONG型字段的处理问题 [求助]登陆管理服务器问题(9i) 创建记录类型出错急救 pl/sql问题。 select * from dba_users where ...的奇怪问题? oracle数据库建立的选项,专用服务器和共享服务器有什么区别,,??? 帮帮我 从效率上考虑,ROWNUM = 1应该放在WHERE条件中的最前面还是最后面?
getDBConnection();
stmt = dbConnection.prepareStatement(queryStr);
resultCount = stmt.executeUpdate();
System.out.println(" dbConnection = " + dbConnection);
System.out.println(" stmt = " + stmt);
if ( resultCount != 1 ){
System.out.println("queryString is: "+ queryStr);
throw new OrderDAODBUpdateException("ERROR in ORDER_TABLE INSERT !! resultCount " + resultCount);
}else {
queryStr = "SELECT ordernum.currval from " + DatabaseNames.ORDER_TABLE;
ResultSet rs = stmt.executeQuery(queryStr);
if ( !rs.next() ) {
throw new OrderDAOAppException("ERROR in selecting OrderId !!");
} else {
oid = rs.getInt(1);
if (oid < 1)
throw new OrderDAOAppException("ERROR in getting OrderId !! orderId = "+ oid);
}
} // end else
} catch(SQLException se) {
se.printStackTrace();
throw new OrderDAOSysException("SQLException occured in insertOrder");
} finally {
try {
if(stmt != null) stmt.close();
closeConnection();
} catch(SQLException se) {
throw new OrderDAOSysException("SQLException while closing statement and connection");
}
} // end finally