I have written a method that will return an Object[][]
to use as the data for a JTable
. I read the data in from a Microsoft Access Database and then put each piece of information into a cell in the Object [][]
. My problem is the return statement of my method which gives me a RuntimeException
. When I use a System.out.println()
to print out each element of the object all the data is there and it works fine, but when it gets to the returning of that object then it falls through.
public Object [] [] AllWorldBestTimes() throws SQLException
{
DatabaseConnection connection = new DatabaseConnection();
ResultSet result = connection.SelectStatements("SELECT * FROM WorldBestTimes");
count = 24;
Object [] [] data = new String[count][4];
int row = 0;
while(row < count)
{
data [row][0] = result.getString(1);
data [row][1] = result.getString(2);
data [row][2] = result.getString(3);
data [row][3] = result.getString(4);
result.next();
System.out.println(data [row][0]);
System.out.println(data [row][1]);
System.out.println(data [row][2]);
System.out.println(data [row][3]);
row++;
}
connection.close();
return data;
}
The above code displays the exact data that needs to be returned when it is printed out but returning it gives me a RuntimeException
.
UPDATE
Stacktrace:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - unreported exception java.sql.SQLException; must be caught or declared to be thrown