jtable to database

Hi

i would like to ask on how to save all data on jtable to my database.

cause the data on jtable is imported only from excel files.

can anyone know the solution for that?

[196 byte] By [lesbona] at [2007-11-27 10:53:33]
# 1

use table.getValueAt(row,col).

next time post in swing forum.

Yannixa at 2007-7-29 11:44:51 > top of Java-index,Java Essentials,Java Programming...
# 2

do you have a sample code im a newbie?

lesbona at 2007-7-29 11:44:51 > top of Java-index,Java Essentials,Java Programming...
# 3

i know there is a better solution to this problem.

save the data by row like this:

String sqlString = "update table set firstname = ?, lastname = ? where id = ?";

PreparedStatement pstmt = con.prepareStatement(sqlString);

for(int i = 0; i < table.getRowCount; i++){

con.setAutoCommit(false);

pstmt.setString(1,table.getValueAt(i, column1).toString());

pstmt.setString(2,table.getValueAt(i, column2).toString());

pstmt.setInt(3,4);

pstmt.executeUpdate();

con.commit();

}

Yannixa at 2007-7-29 11:44:51 > top of Java-index,Java Essentials,Java Programming...