1

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?

0

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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?

1 Comment

I knew there might be such applications,I was intending on implementing one of my own,thanks for your help :)
2

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)!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.