0
拉動了數據我想從Access數據庫提取數據並填充,用下面的代碼問題在從ACCESSDB
String[] tableColumnsName = {"col 1","col 2","col 3"};
DefaultTableModel aModel = (DefaultTableModel) jTable2.getModel();
aModel.setColumnIdentifiers(tableColumnsName);
try {
// the query
rs = db.query("SELECT * FROM Students ");
} catch (SQLException ex) {
Logger.getLogger(RegisterGUI.class.getName()).log(Level.SEVERE, null, ex);
}
// Loop through the ResultSet and transfer in the Model
java.sql.ResultSetMetaData rsmd = null;
try {
rsmd = rs.getMetaData();
} catch (SQLException ex) {
Logger.getLogger(RegisterGUI.class.getName()).log(Level.SEVERE, null, ex);
}
//int colNo = rsmd.getColumnCount();
try {
while(rs.next()){
Object[] objects = new Object[10];
// tanks to umit ozkan for the bug fix!
for(int i=0;i<10;i++){
objects[i]=rs.getObject(i+1);
}
aModel.addRow(objects);
}
} catch (SQLException ex) {
Logger.getLogger(RegisterGUI.class.getName()).log(Level.SEVERE, null, ex);
}
jTable2.setModel(aModel);
}//GEN-LAST:event_jButton2ActionPerformed
我能夠從一個提取數據。我怎樣才能從另一張桌子上拉出來?
非常感謝你 – Pragadees
我得到一個錯誤java.sql.SQLException:[Microsoft] [ODBC Driver Manager]無效的描述符索引 – Pragadees
嘗試更新... – MadProgrammer