I want to add db(MySql) data to a single specific column in jTable when there is three columns. From this below coding the data automatically add to the 1st column, but I want to add it to the 2nd column in Jtable. Please help me ..i'm new to netbeans !!!
Connection con = Driver.connect();
ResultSet rst = Handler.getData(con, "select lec_name from lecturer");
DefaultTableModel dtm = (DefaultTableModel)jTable1.getModel();
while (rst.next()) {
Object ob []= {rst.getString(1)};
dtm.addRow(ob);
}
Each element in the Object array is a column. This means, you simply means you just need to fill the row array with the correct values
Object ob []= {rst.getString(1), rst.getString(2), rst.getString(3)}};
dtm.addRow(ob);
This of course assumes you've added the appropriate columns to the model in the first place