Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

How To Bind Mssql Table With Jtable


2 replies to this topic

#1 tinoymalayil

    Premium Member

  • Kontributors
  • PipPipPipPipPipPipPipPip
  • 154 posts
  • Gender:Male
  • Location:India
  • myCENT:23.11

Posted 20 July 2009 - 07:55 AM

How to Bind a MS SQl Table with JTable in Java Swing....

Please reply if anyone knows....

#2 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 19 October 2009 - 03:03 PM

How To Bind Mssql Table With JtableHow To Bind Mssql Table With Jtable

Here is a sample code from my project... I hope it will help you.

 

void getTableData()   {   Vector<String> heading = new Vector<String>();   heading.AddElement("Code");   heading.AddElement("First Name");   heading.AddElement("Last Name");   Vector data = new Vector();   try   { String table="tbl_cand_primary"; DB_Query.SelectAllQuery(table, null);   while(DB_Query.Rs.Next())   {   codeT = DB_Query.Rs.GetString("cand_code");   fnameT = DB_Query.Rs.GetString("fname");   lnameT = DB_Query.Rs.GetString("lname");   Vector<String> tmp = new Vector<String>();   tmp.AddElement(codeT);   tmp.AddElement(fnameT);   tmp.AddElement(lnameT);   data.AddElement(tmp);   }   }   catch(SQLException e)   { //   }   finally   { if (DBConnect.Conn != null) { try { DB_Query.Rs.Close(); DB_Query.S.Close (); DBConnect.Conn.Close (); } catch (Exception e) {   //Ignore   } }   }   table = new JTable(data, heading);   v=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;   h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;   jsp = new JScrollPane(table,v,h);   panel_Content.SetLayout(null);   jsp.SetBounds( 0, 0, 500, 150 );   panel_Content.Add( jsp );   }

-reply by Prashant Sharma

 



#3 Guest_Innocent Opare_*

  • Guests

Posted 09 December 2010 - 11:18 AM

View Posttinoymalayil, on 20 July 2009 - 07:55 AM, said:

How to Bind a MS SQl Table with JTable in Java Swing....

Please reply if anyone knows....
Make sure netbeans is connected to your mySQL. Entiy bean class should be created automatically, if not create it. then drag and drop your JTabel on your JFrame. next click on service and locate the Database table to used and also drag and drop on the JTable.




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users