Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Operation must use an updateable query

I am asking this b/c I can't view any of the solutions!
I get the error above when I try to run this code...


String sql1 = "INSERT INTO [Sheet2$] (projNum, projName, fMonth, budget) "+ "VALUES (?, ?, ?, ?)";
ps = con.prepareStatement(sql1);
while(count < 12){
                      blah blah blah;
                       ps.addBatch();
                       count++;
}

ps.executeUpdate();
0
webhsu
Asked:
webhsu
  • 5
  • 4
  • 4
1 Solution
 
CEHJCommented:
The driver will have to support the operation you're trying. Try getting rid of the batch first
0
 
webhsuAuthor Commented:
I'm able to read from an excel spreadsheet - but it's writing back to another sheet that I'm having an issue with.
I commented out the addbatch line and am still getting the same error.

the error is when I run the ps.executeUpdate...
0
 
CEHJCommented:
Which driver are you using?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
objectsCommented:
> ps.executeUpdate();

should be ps.executeBatch()
0
 
webhsuAuthor Commented:
I get the same error using executeBatch();

My driver:
      public static final String DRIVER_NAME = "sun.jdbc.odbc.JdbcOdbcDriver";

      public static final String DATABASE_URL = "jdbc:odbc:Budget";

Budget is an xls file.
0
 
webhsuAuthor Commented:
Well - Budget is a datasource for an excel spreadsheet.
Thanks for your help guys/gals!
0
 
CEHJCommented:
Not even sure if that driver + Excel supports PreparedStatement
0
 
objectsCommented:
try using a standard statement
0
 
webhsuAuthor Commented:
I now have this non-preparedstatement update:
---
sql1 = "INSERT INTO [Sheet2$] (projNum, projName, fMonth, budget) "+ "VALUES "+projNum+"', '"+ projName+"', " + count+1 +","+ month[count]+")";

int nn = stmt.executeUpdate(sql1);
----


I print out sql1:
INSERT INTO [Sheet2$] (projNum, projName, fMonth, budget) VALUES ('04TASSSTS', 'TAS - Silo Support - Core Technology - MLIM EMEA', 01,0.0)

java.sql.SQLException: [Microsoft][ODBC Excel Driver] Operation must use an updateable query.
      at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
      at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
      at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
      at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
      at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(Unknown Source)
      at updateBudget.main(updateBudget.java:84)



0
 
objectsCommented:
can u post your complete code
0
 
objectsCommented:
And make sure your data source is writeable
0
 
webhsuAuthor Commented:
dang - that was easy.

Thanks Objects and CEHJ - I actually wish I could give CEHJ some points!
0
 
CEHJCommented:
>>I actually wish I could give CEHJ some points!

Well you could - it's quite possible to split points ;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now