conn = JDBCConnection.getConnection();
String sql = "INSERT INTO t_user (Account, Password) VALUES (?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, account);
pstmt.setString(2, password);
pstmt.executeUpdate(sql);
rs=pstmt.executeQuery();
if (rs.next()) {
user = new User();
user.setAccount(account);
user.setPassword(password);
}

解决方案 »

  1.   

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?,?)' at line 1
      

  2.   

    pstmt.setString(0, account);
    pstmt.setString(1, password);
      

  3.   

    rs=pstmt.executeQuery();
    if (rs.next()) {
    user = new User();
    user.setAccount(account);
    user.setPassword(password);
    }
    你这写法有问题把,rs是结果,没见你从rs取结果!还有就是pstmt.executeQuery();执行查询时候应该写个select的sql把!