我遇到了这个问题,我无法弄清楚这段代码有什么问题。我将 jdbc 和 ms 管理系统用于数据库及其连接。
代码:
try {
//create user
preparedStatement = conn.prepareStatement("INSERT INTO Users(name, pass, type) VALUES (nick=?,pass=?,type=?)",
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
preparedStatement.setString(1, user.getNickName());
preparedStatement.setString(2, user.getPassword());
preparedStatement.setInt(3, type);
rs = preparedStatement.executeQuery();
System.out.println(rs.toString());
catch (Exception e) {
System.out.println("Exception: " + e);
}
错误:
Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '='.