Results 1 to 3 of 3
- 01-12-2012, 01:56 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 3
- Rep Power
- 0
Using jTable to display query result
hey guys.
i'm new here and i'm sorry if this had been posted before. i am trying to display a query result from ms access into a jTable through a search function.
here is my code:
the item that i need to display in the jTable is this part:Java Code:private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ String woorder = jTextField1.getText(); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:scmdatabase"); PreparedStatement st=con.prepareStatement("select * from table1 where workorderno = ?"); st.setString(1, woorder); ResultSet rs=st.executeQuery(); while(rs.next()){ System.out.println(rs.getString("invoiceno")+" "+rs.getString("invoicedate")+" "+rs.getString("amount")); } } catch(Exception e){ System.out.println(e); }
really hope that you guys can help me.Java Code:System.out.println(rs.getString("invoiceno")+" "+rs.getString("invoicedate")+" "+rs.getString("amount"));
- 01-12-2012, 03:46 AM #2
Re: Using jTable to display query result
Read the API for JTable and follow the link to the Swing tutorial on How to Use Tables.
Then give it a shot yourself and if you can't get the desired result, post your best efforts with a clear description of where you're stuck, in the form of an SSCCE (Short, Self Contained, Compilable and Executable) example.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 01-13-2012, 02:29 AM #3
Member
- Join Date
- Jan 2012
- Posts
- 3
- Rep Power
- 0
Re: Using jTable to display query result
thanks darryl,
i already figured out how to display the result in the jTable.
my only problem for now is i want to calculate sum of the third column of the jTable. i just can't figured out on how to do it.
i've tried the getvalueat method, but i don't know how to do the looping of addition and to set the class type.
Similar Threads
-
Can someone please explain to me the proper way to display the result of a SQL query
By Turk80 in forum New To JavaReplies: 1Last Post: 04-11-2011, 01:39 AM -
Empty result set with dynamic query and row handler in iBATIS
By richteri in forum JDBCReplies: 1Last Post: 05-20-2010, 07:58 AM -
column result query
By vikashkumar in forum JDBCReplies: 0Last Post: 04-03-2009, 02:23 PM -
Help!! how to turn query result to string
By stefanybaez in forum Advanced JavaReplies: 2Last Post: 12-11-2008, 11:42 AM -
Export query result, procces is to slow
By Daniel in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 06-28-2007, 06:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks