Solved

How to display an SQL query into a JTable in Netbeans

Posted on 2009-04-04
6
850 Views
Last Modified: 2013-12-29
I currently have a TableModel bound to a table in the database, the values and columns output fine. However, is there any possible way to make an sql query rather than display one table. I have made an SQL View from Netbeans under Services/Databases for the database, but can't seem to use it anywhere for the table model.
0
Comment
Question by:namsu55
  • 3
  • 3
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24085722
You can make the query using a SwingWorker (see excellent docs) and then set a new DefaultTableModel
0
 

Author Comment

by:namsu55
ID: 24086017
But would I be able to use foreign keys. Two joined tables in one table model through netbeans.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24086111
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:namsu55
ID: 24086624
How do I manipulate the Table Model in Netbeans for a JTable.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 24090444
You just set it directly
table1.setModel(model);

Open in new window

0
 

Author Comment

by:namsu55
ID: 24091280
Thanks CEHJ just having a go at it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now