Jump to content
xisto Community
Sign in to follow this  
tinoymalayil

How To Bind Mssql Table With Jtable

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.