Am trying to create a JTable application but when i try to run the program in netbeans it bring an error on the addRow() and removeRow() and yet when i run it in the commandPrompt it works well what could be the problem.
below is a snippet of the code block
private void RetrieveData ()
{
try
{
int row = tmodel.getRowCount();
while(row > 0)
{
row--;
tmodel.removeRowSelectionInterval(0,3);
}
//execute query
ResultSet rs = st.executeQuery("Select * from student_info");
//get metadata
ResultSetMetaData md = rs.getMetaData();
int colcount = md.getColumnCount();
Object[] data = new Object[colcount];
//extracting data
while (rs.next())
{
for (int i=1; i<=colcount; i++)
{
data[i-1] = rs.getString(i);
}
tmodel.addRowSelectionInterval(0,3);
}
}
catch(Exception e) {System.out.println(e); }
}