?
Solved

Operation must use an updateable query

Posted on 2005-03-10
13
Medium Priority
?
235 Views
Last Modified: 2008-01-09
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
Comment
Question by:webhsu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 4
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13510582
The driver will have to support the operation you're trying. Try getting rid of the batch first
0
 

Author Comment

by:webhsu
ID: 13510626
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13510732
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!

 
LVL 92

Expert Comment

by:objects
ID: 13510783
> ps.executeUpdate();

should be ps.executeBatch()
0
 

Author Comment

by:webhsu
ID: 13511109
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
 

Author Comment

by:webhsu
ID: 13511140
Well - Budget is a datasource for an excel spreadsheet.
Thanks for your help guys/gals!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13511208
Not even sure if that driver + Excel supports PreparedStatement
0
 
LVL 92

Expert Comment

by:objects
ID: 13511300
try using a standard statement
0
 

Author Comment

by:webhsu
ID: 13511367
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
 
LVL 92

Expert Comment

by:objects
ID: 13511464
can u post your complete code
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 13511483
And make sure your data source is writeable
0
 

Author Comment

by:webhsu
ID: 13511692
dang - that was easy.

Thanks Objects and CEHJ - I actually wish I could give CEHJ some points!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13511727
>>I actually wish I could give CEHJ some points!

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question