Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Fill a JTable with data from a MySQL database

843806Sep 13 2008 — edited Aug 3 2010
Hi!

I have a JTable calles "table" and I want to fill it with items stored in database. I have set up a connection and the only thing I have to do now is to fill the JTable.
But I don´t know how to that.
String search_str = searchTextField.getText();
String query;
ResultSet rs;
Statement stmt;
query = "SELECT name FROM person WHERE name='"+search_str+"'"; 
stmt = Connect.con.createStatement();
rs = stmt.executeQuery(query);
while(rs.next())
{            
      System.out.println(rs.getString("name"));
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2010
Added on Sep 13 2008
11 comments
6,112 views