select和update、inster之前都用这个函数,当时是用oracle的,但今天换mysql后,出现问题了,怎样改才能都适用于select和inster呢?
public boolean executeUpdate(String sql,KeyValue paramter) throws Exception {
boolean result = false;
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null; try{
conn = DBConnection.getConnection();
stmt = conn.prepareStatement(sql);
initPreparedParamer(stmt,paramter);
rs=stmt.executeQuery();
result = rs.next();
return result;
}catch(java.sql.SQLException ext){
result = false;
throw new Exception("更新信息失败,错误信息:" +ext.toString());
}finally{
if(stmt!=null) stmt.close();
if(conn!=null) DBConnection.releaseConnection(conn);
}
}
public boolean executeUpdate(String sql,KeyValue paramter) throws Exception {
boolean result = false;
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null; try{
conn = DBConnection.getConnection();
stmt = conn.prepareStatement(sql);
initPreparedParamer(stmt,paramter);
rs=stmt.executeQuery();
result = rs.next();
return result;
}catch(java.sql.SQLException ext){
result = false;
throw new Exception("更新信息失败,错误信息:" +ext.toString());
}finally{
if(stmt!=null) stmt.close();
if(conn!=null) DBConnection.releaseConnection(conn);
}
}
executeUpdate 用户返回影响行数的,比如insert和 update
executeUpdate 用户返回影响行数的,比如insert和 update更多的JAVA面试题,Java代码,Java学习资料,请到 JAVA世纪网
更多的数据库面试题,智力面试题,相声,笑话,请到 老紫竹的家