insert query with varchar as data type for primary key

后端 未结 1 1772
北恋
北恋 2021-01-27 22:59

The program is not accepting the query given below-

 public class loginDaos {

       public void create(loginBean bean) {
           ConnectionPool c = Connecti         


        
相关标签:
1条回答
  • 2021-01-27 23:12

    When you are using a PreparedStatement, then you should use the executeQuery(), executeUpdate() or execute() method that does not take a String parameter.

    So to fix the problem use:

    // ....
    pstmt.setString(3, bean.getPassword());
    pstmt.setString(4, bean.getPosition());
    pstmt.executeUpdate();
    

    The MySQL driver implementation has a bug, because the JDBC specification states that the methods accepting a string should throw an SQLException when called on a PreparedStatement or CallableStatement implementation. In this case it only throws the exception because it tries to execute the parametrized query directly.

    0 讨论(0)
提交回复
热议问题