Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error while using sql update statement

 
joy thomas
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
joy thomas
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Filename: a.tif
Description:
File size: 187 Kbytes
[Download a.tif] Download Attachment
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic