例如下程序
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()取不到值???
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()取不到值???
table.getvalueAt(int row, int column)