Solved

How to display an SQL query into a JTable in Netbeans

Posted on 2009-04-04
6
849 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

747 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

11 Experts available now in Live!

Get 1:1 Help Now