急急急!!!如何将JTable中的内容写到相应的数据库的表中

ruinerprince 2008-04-21 11:48:57
例如下程序
Object data[][] = new Object[500][6];
Object name[] = {"号码","姓名","性别","运动队","项目","序号"};
JTable nametable = new JTable(data,name);

try{
conn = DriverManager.getConnection("jdbc:odbc:SQL Server2000","zxm","123");
stmt = conn.createStatement();
int row = nameTable.getRowCount();
int column = nameTable.getColumnCount();
for(int i=0; i<row; i++){
Vector v = new Vector();
for(int j=0; j<column; j++){
v.add(nameTable.getValueAt(i,j));
}
System.out.println(v.get(0).toString());
System.out.println(v.get(1).toString());
System.out.println(v.get(2).toString());
System.out.println(v.get(3).toString());
System.out.println(v.get(4).toString());
System.out.println(v.get(5).toString());
sql = "use TJCUFE insert into ReportingTable values (" + "'" + v.get(0).toString() + "'" + "," +
"'" + v.get(1).toString() + "'" + "," + "'" + v.get(2).toString() + "'" + "," +
"'" + v.get(3).toString() + "'" + "," + "'" + v.get(4).toString() + "'" + "," +
"'" + v.get(5).toString() + "'" + ")";
stmt.execute(sql);
}
conn.close();
}catch(SQLException e2){
e2.printStackTrace();
}

为什么运行时v.get(5).toString()取不到值???
...全文
78 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zwgs1985 2008-05-04
  • 打赏
  • 举报
回复
使用
table.getvalueAt(int row, int column)

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧