tags:

views:

101

answers:

3

I want to write a java program that acts as a user interface to a mysql database,the program should do the following:

1.connect to the database,show available tables in the database

2.display table data

3.modify table data (insert,edit,delete,sort) rows

I've tried to use JDBC only,but couldn't figure out a way to put the table data in a multidimensional array

is there an API i should be using instead of just JDBC?

+2  A: 

No, JDBC is the correct API. Representing DB table data as a multidimensional array is just not a good idea.

Are you aware that there's lots of existing general SQL clients in Java?

Michael Borgwardt
I knew there might be such applications,I was intending on implementing one of my own,thanks for your help :)
Phobia
+3  A: 

Blatent plug for votes: Here is an answer I gave to a similar question, concerning populating a JTable from a JDBC ResultSet. As Michael says, there are a lot of existing SQL clients so it's definitely not worth building your own. However, if you want to populate a JTable with ResultSet data for a reason other than writing your own SQL client from scratch then the linked answer may help.

Essentially the two APIs you'll need are JDBC and Swing (or an alternative such as SWT). I recommend reading back data from your ResultSet on a thread other than Swing's Event Dispatch thread; Otherwise your UI will lock up during large read operations.

Adamski
+1  A: 

This posting shows how to get a list of all the tables a database.

Another blatent plug for votes :) The link provided above by Adamski also contains my two suggestions for populating a JTable from a ResultSet. Its 2 lines of code (when you use the provided ListTableModel)!

camickr