insert query with varchar as data type for primary key

你。 提交于 2019-12-02 09:27:52

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!