java编写的服务器,数据库用Access2010,代码中能正确执行insert,update语句,但数据表中没见记录更新。 20
java编写的服务器,数据库用Access2010,代码中能正确执行insert,update语句,但数据表中没见记录更新。而且成功执行插入后,再查询能查到记录但是数据表...
java编写的服务器,数据库用Access2010,代码中能正确执行insert,update语句,但数据表中没见记录更新。而且成功执行插入后,再查询能查到记录但是数据表中就是看不到该记录,代码:
public boolean UpdateScore(String userName, String password, String score){
String sql = "update info set [score]='"+score+"' where [username]='"+userName+"' " +
"and [password]='"+password+"'";
PreparedStatement pstmt = null;
try {
pstmt = dbConnection.prepareStatement(sql);
int i = pstmt.executeUpdate();
return true;
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
pstmt.close();
} catch (SQLException se) {
se.printStackTrace();
}
}
return false;
}
public boolean InsertScore(String userName, String password, String score){
String sql = "insert into info([username],[password],[score]) values ('"+userName+"','"+password+"','"+score+"')";
PreparedStatement pstmt = null;
try {
pstmt = dbConnection.prepareStatement(sql);
int i = pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
}finally {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return false;
}
求助!!! 展开
public boolean UpdateScore(String userName, String password, String score){
String sql = "update info set [score]='"+score+"' where [username]='"+userName+"' " +
"and [password]='"+password+"'";
PreparedStatement pstmt = null;
try {
pstmt = dbConnection.prepareStatement(sql);
int i = pstmt.executeUpdate();
return true;
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
pstmt.close();
} catch (SQLException se) {
se.printStackTrace();
}
}
return false;
}
public boolean InsertScore(String userName, String password, String score){
String sql = "insert into info([username],[password],[score]) values ('"+userName+"','"+password+"','"+score+"')";
PreparedStatement pstmt = null;
try {
pstmt = dbConnection.prepareStatement(sql);
int i = pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
}finally {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return false;
}
求助!!! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询