|
我在java中写了一段更新数据的代码,可是用系统提供的调用方法(getValueBySQL或queryData),倒是都能更新字段,可是也抛出异常,请问,调用sql更新语句,使用什么方法,有没有关于DataUtils各种方法的详细介绍,谢谢啊!
public static JSONObject xiugaimima(JSONObject params, ActionContext context) throws SQLException, NamingException {
Connection conn = context.getConnection(DATASOURCE_KAJCPAY);
String user = params.getString("user");
String password = params.getString("password");
String count = "";
try{
String sql = "update BF_Basic_Company set password=" +password +" where username='"+user+"'";
System.out.println(sql);
JSONObject ret = new JSONObject();
try{
//DataUtils.getValueBySQL(conn, sql, null).toString();
DataUtils.queryData(conn, sql, null, ret, null, null);
count="ok";
}
catch(Exception e){
count="fail";
}
ret.put("xiugaimima", count);
return ret;
} finally {
conn.close();
}
}
|
|