Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / October 2004

Tip: Looking for answers? Try searching our database.

how to link Microsoft Access database to JTable ....

Thread view: 
nickneo - 08 Oct 2004 15:40 GMT
i am stucked  at a point such that i m getting errors when i  try to link
database  to a JTable component in Java..
   What i neeed  is a solution to link database and JTable so that i can
display the contents in  database  in a table..pls help me...My project
submission date is fast approaching...
mail me to nibin012@gmail.com...
Fredy Fischer - 08 Oct 2004 17:19 GMT
You have to create a JTableModel that represents your Table.
Additionally, you might want to create a fillWithData-Methode, that
fills the table with the values from the DB (e.g. select * from table).
Also you have to rewrite the setValueAt-Methode:

   public void setValueAt(Object value, int row, int col) {
       Vector rowData = (Vector)data.elementAt(row);
       rowData.setElementAt(value,col);
       data.setElementAt(rowData,row);

       String query = 'your update-query for this field'
      ...the code to send this to your db.

       fireTableCellUpdated(row, col);

   }

Then create your Swing Code:

e.g.:
JTable table = new JTable(new MyTableModel("select * from table"));
JScrollPane scrollPane = new JScrollPane(table);

If you want to add some new rows to your table, you have to implement
your own methods.

Hope this helps.  

Regards Fredy

> i am stucked  at a point such that i m getting errors when i  try to link
>database  to a JTable component in Java..
>    What i neeed  is a solution to link database and JTable so that i can
>display the contents in  database  in a table..pls help me...My project
>submission date is fast approaching...
>mail me to nibin012@gmail.com...
Fredrik Bertilsson - 09 Oct 2004 16:39 GMT
> i am stucked  at a point such that i m getting errors when i  try to link
> database  to a JTable component in Java..
>     What i neeed  is a solution to link database and JTable so that i can
> display the contents in  database  in a table..pls help me...My project
> submission date is fast approaching...
> mail me to nibin012@gmail.com...

You can use http://butler.sourceforge.net. Try the class
RecordListTable that are a database-aware JTable.

/Fredrik


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.