使用preparedStatement进行增删改操作出现错误,可以进行查询,而使用Statement是可以进行增删改查操作,用错误内容百度说是权限问题,而jdbc登陆的用户是具有所有权限的,小白求解!!
提示错误信息代码:
@Test
public void preparedStatement() {
String sql = "INSERT INTO test.student(name,age) values (?,?);";
Connection c = null;
java.sql.PreparedStatement pre = null;
try {
c = getConnection();
pre.setString(1, "张琳");
pre.setInt(2, 18);
pre = c.prepareStatement(sql);
pre.executeQuery();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
close(c,pre,null);
}
}