Dharshu
Dharshu

Reputation: 11

updating error in JSP, eclipse


- Can not issue data manipulation statements with executeQuery().


UPDATING JAVA CODE

MultiDBManager db8=new MultiDBManager(uif);
String updateString = "UPDATE pklrsc SET pr_prod_rate="+rate+" , pr_ln_cst="+cost+" WHERE pr_rsc_cde= "+component+" ";
db8.execSQL(updateString);

.java FILE CODE

    public ResultSet execSQL(String sql) throws SQLException {
    System.out.println("execSQL");
    return super.execSQL(processQuery(sql));
    }

private String processQuery(String sql){
System.out.println("processQuery");
return mdb.getCacheDB().procSQL(sql, false);
}

ERROR MESSAGE

value i: 1
component: ACODE0001
rate: 2.00
cost: 261.22
execSQL
processQuery
Execute = UPDATE c66_p30_BIS.pklrsc SET pr_prod_rate=2.00 , pr_ln_cst=261.22 WHERE pr_rsc_cde= ACODE0001 
Nov 4, 2010 4:54:49 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
 at com.mysql.jdbc.Statement.checkForDml(Statement.java:398)

Upvotes: 1

Views: 633

Answers (2)

Andreas Dolk
Andreas Dolk

Reputation: 114787

You're using a hidden executeQuery call to update values in the database. That's not allowed (see exception).

This method call actually causes your trouble:

mdb.getCacheDB().procSQL(sql, false);

Find an alternative to send update statements (Actually I don't know what API you're using here)

Upvotes: 1

Bozho
Bozho

Reputation: 597114

You must call executeUpdate() when using INSERT/UPDATE/DELETE, rather than executeQuery()

Also note that using code in JSP, which is a view technology, is not encouraged.

Upvotes: 2

Related Questions