当前位置: 代码迷 >> J2EE >> preparestatement 使用有关问题-着
  详细解决方案

preparestatement 使用有关问题-着

热度:642   发布时间:2016-04-22 01:31:55.0
preparestatement 使用问题----着急
preparestatement 可以发送操作表结构的语句吗?

例如创建表,增加、删除、修改字段等


我总是报错,求解错误如下,增删改查都是这个异常,好奇怪!!!!


Exception--create table---:Incorrect syntax near '@P0'.

------解决方案--------------------
private static PreparedStatement pstmt = null;
加载驱动 获得连接之后 开始进行如下操作
pstmt=conn.prepareStatement("insert into dept2 values(?,?,?)");
pstmt.setInt(1,deptno);
pstmt.setString(2, dname);
pstmt.setString(3,loc);
pstmt.executeUpdate();