File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes error while using sql update statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "error while using sql update statement" Watch "error while using sql update statement" New topic
Author

error while using sql update statement

joy thomas
Greenhorn

Joined: Jul 01, 2011
Posts: 5
while running the following program i got a runtime error:

exception [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.



help me solve the problem

[Edit: put code between [code] and [/code] ubb code blocks]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11523
    
100

Works for me.

One of the things that was asked in the identical topic on Java Forums was how you had set up your ODBC connection. This was kind of skipped over since you said that you had been able to do queries without problems. But it can be helpful if you provide that information - there may be something of interest. For example, to test this I setup:



By the way, you should BeForthrightWhenCrossPostingToOtherSites (read the link to see why).

In looking at your source code I noticed that you do not ever close your result sets / statements / connections. This is a really bad idea - you wont really know what state your transaction was in.

The other topic also mentions you having some DDL in your original posting. Perhaps that might provide clues as to what is happening.

Did you create the database using your Java code, or did you use Microsoft Access?


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
joy thomas
Greenhorn

Joined: Jul 01, 2011
Posts: 5
Andrew Monkhouse wrote:Works for me.

One of the things that was asked in the identical topic on Java Forums was how you had set up your ODBC connection. This was kind of skipped over since you said that you had been able to do queries without problems. But it can be helpful if you provide that information - there may be something of interest. For example, to test this I setup:



By the way, you should BeForthrightWhenCrossPostingToOtherSites (read the link to see why).

In looking at your source code I noticed that you do not ever close your result sets / statements / connections. This is a really bad idea - you wont really know what state your transaction was in.

The other topic also mentions you having some DDL in your original posting. Perhaps that might provide clues as to what is happening.

Did you create the database using your Java code, or did you use Microsoft Access?





i don't understand. i had already done with the dsn . it still does not work. i created the database using Microsoft Access
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11523
    
100

Yes, but we have not seen your DSN, so we can't see if anything is wrong with it. For example, there is a little checkbox to specify whether the database is read-only or not. Since we have no idea what your DSN has been configured as, we are going to ask questions about it.

Here is an example of what happens when you set that check-box to read-only, then try to do a read immediately followed by an insert:


Look familiar?

In the other forum, Tolls asked if your database was already open - this is a very important question, since Microsoft Access is not a multi-user database. If you are running Microsoft Access while you simultaneously try to run Java code you might see this error. Same with running any other two applications simultaneously.

Another possibility is that the database is in a directory that you do not have full rights to.
joy thomas
Greenhorn

Joined: Jul 01, 2011
Posts: 5
Andrew Monkhouse wrote:Yes, but we have not seen your DSN, so we can't see if anything is wrong with it. For example, there is a little checkbox to specify whether the database is read-only or not. Since we have no idea what your DSN has been configured as, we are going to ask questions about it.

Here is an example of what happens when you set that check-box to read-only, then try to do a read immediately followed by an insert:


Look familiar?

In the other forum, Tolls asked if your database was already open - this is a very important question, since Microsoft Access is not a multi-user database. If you are running Microsoft Access while you simultaneously try to run Java code you might see this error. Same with running any other two applications simultaneously.

Another possibility is that the database is in a directory that you do not have full rights to.




i have sent the dsn as attachment


[Download a.tif] Download

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11523
    
100

OK, the DSN looks reasonable.

How about the other questions asked?

(By the way - there is no need to quote my responses if you are not going to refer to them or answer them).
joy thomas
Greenhorn

Joined: Jul 01, 2011
Posts: 5
Andrew Monkhouse wrote:
In the other forum, Tolls asked if your database was already open - this is a very important question, since Microsoft Access is not a multi-user database. If you are running Microsoft Access while you simultaneously try to run Java code you might see this error. Same with running any other two applications simultaneously.

Another possibility is that the database is in a directory that you do not have full rights to.


MS - Access is not open while trying to run the code.... and the CUSTOMER.accdb file is the documents directory... i am using windows 7 operating system.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error while using sql update statement