• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

inserting Jtable cell values

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic