Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Displaying database result, In Java!

views
     
TSfelixwhoals
post Feb 2 2006, 12:50 AM, updated 20y ago

Casual
***
Junior Member
455 posts

Joined: Oct 2005
From: Birmingham, UK


Hey guys, this is pretty simple:

rs = stmt.executeQuery("SELECT * FROM Customers") ;
printResultSet(System.out, rs) ;
rs.close() ;

When I put this, my java program display all it all on the screen (command line)
I'm not sure how to put them into GUI but is there anyway I could use message box to display that result?

I tried to do JOptionPane.showMessageDialog(null, rs); but i can't display the results.. any ideas?

TSfelixwhoals
post Feb 2 2006, 07:57 AM

Casual
***
Junior Member
455 posts

Joined: Oct 2005
From: Birmingham, UK


I'm just a beginner in this GUI stuff... If anyone suggesting me to use GUIs.. how shall I put it in there? Any source code that I can copy? I've searched from google and yahoo but I just can't think of how to put that 'rs' into the GUI itself.. can someone help me? I have used this Jframe:

WindowUtilities.setNativeLookAndFeel();
JFrame f = new JFrame("This is a test");
f.setSize(400, 150);
Container content = f.getContentPane();
content.setBackground(Color.white);
content.setLayout(new FlowLayout());
content.add(new JButton("Button 1"));
f.addWindowListener(new ExitListener());
f.setVisible(true);

This adds Button to it, is there anyway I could add that rs into it?
TheUrbNorm
post Feb 2 2006, 10:10 PM

On my way
****
Senior Member
557 posts

Joined: Apr 2005



QUOTE
JLabel label = new JLabel("Add your resultset here");
frame.getContentPane().add(label);
You just need to add the label component and put your resultset there. Of course you can iterate the resultset first and create new JLabel instance for each row of your resultset.

Hope that's help. Happy learning. Try google around for answer and tutorial. It will be easier that posting here in the forum..... biggrin.gif

 

Change to:
| Lo-Fi Version
0.0202sec    1.67    5 queries    GZIP Disabled
Time is now: 23rd December 2025 - 08:42 PM