Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get Mysql database value in Jframe table without creating coding for Jtable
    text
    copied!<p>i have create student table like following fields Stuid, studname, mark1,mark2 in Mysql Database. and also create a table using JFrame( source,design) after that i wrote the following code in source side, then drag the table from the Swing controls.</p> <pre><code>public void DbConnection(){ try { Class.forName("com.mysql.jdbc.Driver");//Connection establishment to the database String username = "root"; String password = "root"; String Database = "jdbc:mysql://localhost:3306/project"; Conn = DriverManager.getConnection( Database, username, password ); System.out.println("*** Connect to the database ***"); String Query = "Select * from StudentMaster"; Statement smnt = Conn.createStatement(); ResultSet results = smnt.executeQuery( Query ); ResultSetMetaData metaDt = results.getMetaData(); System.out.println(metaDt); int cols = metaDt.getColumnCount(); for(int i=1;i&lt;cols;i++){ columnNames.addElement (metaDt.getColumnName(i)); } while(results.next()){ Vector row= new Vector(cols); for(int i=1;i&lt;=cols;i++){ row.addElement(results.getObject(i)); } data.addElement(row); } results.close(); smnt.close(); Conn.close(); //Close Connection to the database } catch(Exception e) { System.out.println(e); } } </code></pre> <p>it's connecting with Mysql Database, but it's not showing the DBtable value in Jframe Table. how i can get the value in table(Jframe table control) without creating a code for table. if i double click on table i don't know where i write table code. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload