java.sql.SQLException: ORA-00933: SQL 命令未正确结束
publicintupdateUser(Userusers){Connectionconn=null;Stringsql="updateuserssetusername=...
public int updateUser(User users) {
Connection conn = null;
String sql = "update users set username=?, gender=?, age=?, tel=?, address=?, userroles=? where userid=?";
PreparedStatement pstmt = null;
int rows = 0;
int index = 0;
conn = ConnectionManager.getConnection();
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(++index, users.getUsername());
pstmt.setString(++index,users.getGender());
pstmt.setInt(++index, users.getAge());
pstmt.setString(++index,users.getTel());
pstmt.setString(++index,users.getAddress());
pstmt.setString(++index,users.getUserroles());
pstmt.setInt(++index,users.getUserid());
rows = pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
this.close(conn,pstmt);
} catch (Exception e) {
e.printStackTrace();
}
}
return rows;
}
sql语句在oracle里测试没有问题,但在tomcat测试时,提示
java.sql.SQLException: ORA-00933: SQL 命令未正确结束,
数据库的数据也能成功修改,请高人指点, 展开
Connection conn = null;
String sql = "update users set username=?, gender=?, age=?, tel=?, address=?, userroles=? where userid=?";
PreparedStatement pstmt = null;
int rows = 0;
int index = 0;
conn = ConnectionManager.getConnection();
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(++index, users.getUsername());
pstmt.setString(++index,users.getGender());
pstmt.setInt(++index, users.getAge());
pstmt.setString(++index,users.getTel());
pstmt.setString(++index,users.getAddress());
pstmt.setString(++index,users.getUserroles());
pstmt.setInt(++index,users.getUserid());
rows = pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
this.close(conn,pstmt);
} catch (Exception e) {
e.printStackTrace();
}
}
return rows;
}
sql语句在oracle里测试没有问题,但在tomcat测试时,提示
java.sql.SQLException: ORA-00933: SQL 命令未正确结束,
数据库的数据也能成功修改,请高人指点, 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询