AllExperts > Experts 
Search      

Java

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Java Answers
Question Library

Ask a question about Java
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Artemus Harper
Expertise
I have a BS in computer science and am working towards a Masters degree.

Experience
I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection, and Java java.nio.* knowledge of Java bytecode and annotations. Basics in c++ and c#
 
   

You are here:  Experts > Computing/Technology > Focus on Java > Java > updating JTable(URGENT)

Topic: Java



Expert: Artemus Harper
Date: 7/2/2008
Subject: updating JTable(URGENT)

Question
i want to edit the cells in JTable which takes its data from a MS-Access database and those edits should get saved in the database.i defined the setValueAt ,getValueAt IN TABLEMODEL and have made a class implementing TableModelListener and called that in the main class (main class containing the jtable).i am able to change the values in cell but the values are not being saved on clicking of a button "update" .
PLEASE HELP ME AS SOON AS POSSIBLE.

Answer
In your Connection object (assuming you are using the java.sql package) you would first turn off auto commit in the Connection interface, e.g. con.setAutoCommit(false). Then you any changes made should be done though the updateXXX method in ResultSet. When you want to save the changes you can call commit() in the Connection interface, or if you want to revert you can call rollback().

There is no reason to have a table listener if you are already implementing the setValueAt method.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.