I need some advice on the way I'm should be doing something like this...

My main GUI is composed of a JTable and query box for custom SQL user queries.
I execute a SQL query, from the ResultSet, map the ResultSet an ArrayList<Object>, parse it to a tableModel class extends AbstractTableModel and display it in a JTable and hope it work.

I was told by teacher that it's also a good idea to say make a class for each table to hold the data types and map ResultsSets to that table class... I didn't quite understand and is confused. I'm not sure what it really means but I can map classes for each table to store data, but I get the resultset = statement.executeQuery(...), how am I supposed to use those classes that represent each table? ...

Recommended Answers

All 3 Replies

have you learned anything at all?
Your teacher told you exactly what to do, any more detailed and he'd have had to write the code for you.

It's not that I don't know how to write classes but how to use them.

I can have data classes for each table with setters and getters but when you run a SQL query you make the connection and execute the query from the statement to get the ResultSet. How am I suppose to use the classes that represent the table? Or is there a way to run the query against the classes or something and get results somehow from that?

Another problem is inorder to make the object/class for each table, you'll have to know it's expected types when making such class from the ResultSet. So if a class have a name (String), age (int) you would call .getString(..) and getInt(..() to make the class... But if there's a custom query how am I suppose to map to a already defined class now...

Well anyone?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.