2017-08-29 102 views
-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(); 

} 

任何人都可以澄清呢?

+0

这将是更好,如果你在qusetion – sForSujit

+1

的executeQuery()发布您的代码需要一个select语句。使用executeUpdate()。 –

+0

是的,我知道,我会用。但是为什么它在eclipse中工作呢? –

回答

0

GlassFish服务器内部具有ojdbc7dms.jar,它不允许用于DML操作的executeQuery()方法。 正因为如此只有我们正在

值java.sql.SQLException:SQL字符串不是查询异常