62,621
社区成员
发帖
与我相关
我的任务
分享
public static int insert() {
int flag = 1;
try
{
/**
/* 相关操作
*/
throw new Exception("asdf");
}
catch (Exception e)
{
flag = 2;
}
return flag;
}
public int executeUpdate(String sql) throws Exception
{
try{
dbConn = getConn() ; //get connection
if( dbConn == null)
return -1;
if( stmt != null ) {
stmt.close() ;
stmt = null ;
}
stmt= dbConn.createStatement(); //get statement
if(stmt == null)
return -2;
stmt.executeUpdate(sql); //execute
return 0;
} catch(Exception e) {
System.out.println( "executeUpdate[ "+ sql + "] fail. " + e.getMessage() );
return -99;
} finally {
try {
if(stmt!=null){
stmt.close();
stmt = null;
}
}catch(Exception e) {
System.out.println( "Err: executeUpdate() close stmt fail. ") ;
return -88;
}
}
}