A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Swing / AWT / SWT
Author
inserting Jtable cell values
dev
Greenhorn
Joined: Jan 14, 2002
Posts: 2
posted
Jan 14, 2002 20:47:00
0
Hi all..
here i want to insert Jtable cell values into database...plz can any one help me out with code..
thanks in advance
dev
Jagan Reddy
Greenhorn
Joined: Nov 11, 2001
Posts: 7
posted
Jan 15, 2002 02:43:00
0
Hi,
I think this code might help u out.
for(int i=0;i<table.getRowCount();i++) { //table is the name of ur
JTable
String
sbValues = "insert into table values(";//table is the name of the table in the database where data is to be inserted
String sbData = "";
for(int j=0;j<table.getColumnCount();j++) {
String s2 =(String)table.getValueAt(i,j);
if(s2==null)
s2 = "";
sbValues+=s2+",";
}
sbData+=sbValues.substring(0,sbValues.length()-1)+")";
statement.executeUpdate(sbData); //statement is ur statement object.
}
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: inserting Jtable cell values
Similar Threads
JTable
JTABLE
JTable
JTable
JTable
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter