Results 1 to 7 of 7
- 01-24-2009, 09:53 AM #1
Member
- Join Date
- Jul 2008
- Posts
- 22
- Rep Power
- 0
editing jTable then writing new values to database!
hi every one ..
i'm wondering how can i detect that jtable is currently editing and then store the new values to my data base?
i have used the following code:
if(jTable1.isEditing())
{
int index=jTable1.getEditingRow();
if(index!=-1)
{
jTable1.getValueAt(index,0);
sql = "INSERT INTO announcement (ann_txt,cNo) VALUES ('" + jTable1.getValueAt(index,0).toString()+ "','"+ GlobalData.courseNo+ "');";
res = st.executeUpdate(sql);
}
}
was that the right code...if it's.. where should i put this code?
- 01-24-2009, 12:38 PM #2
> was that the right code...
Why, did you get it from an unreliable source?
> where should i put this code?
In your program?
db
- 01-27-2009, 03:17 PM #3
Member
- Join Date
- Jul 2008
- Posts
- 22
- Rep Power
- 0
i'm sorry ...maybe my question was'nt clear..
what i ment is how can i use fireTableChanged when i'm using DefaultTableModel
- 01-27-2009, 03:24 PM #4
DefaultTableModel should fire TableModelChanged events for you. You need to add a listener to the TableModel and figure out what the different events mean. When you see the appropriate event, you can then invoke your database update code.
- 01-27-2009, 04:30 PM #5
Member
- Join Date
- Jul 2008
- Posts
- 22
- Rep Power
- 0
thanks alot "Steve11235"..
but i have another annoying question..
can you give me any links that explain how to -->add a listener to the TableModel
thanks in advance..
- 01-27-2009, 04:35 PM #6
Sun's Java Tutorials cover just about everything.
- 01-27-2009, 05:07 PM #7
Member
- Join Date
- Jul 2008
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
Reading and writing the contents of jtable into a text file
By Manfizy in forum NetBeansReplies: 6Last Post: 12-12-2008, 03:35 PM -
Getting integer values from a JTable
By zikojam in forum New To JavaReplies: 1Last Post: 12-11-2008, 02:06 PM -
writing array values to another class
By ronald christian in forum New To JavaReplies: 27Last Post: 11-07-2008, 04:08 PM -
JTable editing with Mouse
By Gajesh Tripathi in forum AWT / SwingReplies: 0Last Post: 10-11-2008, 08:34 AM -
jTable Cell editing
By mahaling_m in forum AWT / SwingReplies: 0Last Post: 06-23-2008, 08:17 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks