java - JTable swing import database sql -


could provide me example or tutorial on how import data mysql database within jtable within use of gui. tried looking example have not found anything.

hopefully can put question rest

connection db = drivermanager.getconnection( jdbc:mysql://192.168.0.3:3306,<user>,<password>); statement stmt = db.createstatement(); preparedstatement psmt = con.preparestatement("select * db"); resultset rs = psmt.executequery();  // column names int len = rs.getmetadata().getcolumncount(); vector cols= new vector(len); for(int i=1; i<=len; i++) // note starting @ 1     cols.add(rs.getmetadata().getcolumnname(i));   // add data vector data = new vector(); while(rs.next()) {     vector row; = new vector(len);     for(int i=1; i<=len; i++)     {         row.add(rs.getstring(i));     }     data.add(row); }  // create table jtable table = new jtable(data, cols); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -