首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

stmt.executeUpdate(sql);//这句为啥不执行

2013-10-13 
stmt.executeUpdate(sql)//这句为什么不执行?public static void test() throws SQLException{Connection

stmt.executeUpdate(sql);//这句为什么不执行?
public static void test() throws SQLException{

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = JdbcUtils.getConnection();
stmt = conn.createStatement();
String sql = "UPDATE USERTEST SET MONEY=MONEY-10 WHERE USERID=2";
stmt.executeUpdate(sql);//这句为什么不执行?

sql = "select money from USERTEST WHERE USERID=2";
rs = stmt.executeQuery(sql);
float money = 0.0f;
if (rs.next()) {
money = rs.getFloat("money");
}
if(money > 300)
throw new RuntimeException("已经超过最大值!");
} finally {
// 6关闭资源
JdbcUtils.free(conn, stmt, rs);
}
}
[解决办法]
commit

热点排行