tinoymalayil 0 Report post Posted July 20, 2009 How to Bind a MS SQl Table with JTable in Java Swing....Please reply if anyone knows.... Share this post Link to post Share on other sites
iGuest 3 Report post Posted October 19, 2009 How To Bind Mssql Table With JtableHow To Bind Mssql Table With JtableHere 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
iGuest 3 Report post Posted December 9, 2010 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