This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Exception While Updating Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Exception While Updating" Watch "Exception While Updating" New topic

Exception While Updating

Maryam Nouhnejad
Ranch Hand

Joined: Oct 04, 2006
Posts: 39
I get an exception when I want to use update in my database methods.

the exception is :

Exception in thread "main" com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
I wrote the ResultSet this way :

PreparedStatment pstmt = Connection.PreparedStatment("select * from laptop" , ResultSet.TYPE_SCROLL_SENSITIVE , ResultSet.CONCUR_UPDATABEL);

ResultSet rs = pstmt.executeQuery();

(Note that I only use one table)

I don't know what the problem can be... would you please help me?
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Does the table have a primary key?

Next time you post code, please copy-paste instead of typing it in, that is obviously not the actual code you are using.
Maryam Nouhnejad
Ranch Hand

Joined: Oct 04, 2006
Posts: 39
I could solve my problem .
I made a primary key for my table and now I recive no exception .
I agree. Here's the link:
subject: Exception While Updating
It's not a secret anymore!