-2
我们使用executeQuery()
删除表中的数据,使用java代码。当我们使用Eclipse运行程序时,它能够正确删除,但是在构建来源和部署在玻璃鱼服务器中出现错误。java.sql.SQLException:SQL查询字符串不在Glassfish服务器中查询
java.sql.SQLException: SQL string is not Query
手段,我们不应该对DML操作。如果是在eclipse应该甚至不工作的情况下使用executeQuery()
。
下面是我的代码:
PreparedStatement deletePreparedStmt = null;
String sql = "DELETE FROM emp WHERE eno = ?";
try
{
deletePreparedStmt = con.prepareStatement(sql);
deletePreparedStmt.setInt(1,50);
deletePreparedStmt.executeQuery();
con.commit();
}
catch(Exception e)
{
e.printStackTrace();
}
任何人都可以澄清呢?
这将是更好,如果你在qusetion – sForSujit
的executeQuery()发布您的代码需要一个select语句。使用executeUpdate()。 –
是的,我知道,我会用。但是为什么它在eclipse中工作呢? –