I dont know what is wrong with my code but i'm not able to display the data extracted from database on a jtable:(
here is my code
where jTextField1 gives table name and jTextField2 gives id value.
here is my code
Code:
Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); String conURL = "jdbc:mysql://localhost/dbname"; con = DriverManager.getConnection(conURL, "user", "pswrd"); Statement st = con.createStatement(); String query1 = "select name, date, login, logout from " + jTextField1.getText() + " where id = '" + jTextField2.getText() + "'"; ResultSet rs = st.executeQuery(query1); while (rs.next()) { jTable1.setModel(DbUtils.resultSetToTableModel(rs)); } System.out.println(query1); } catch (ClassNotFoundException | SQLException e) { JOptionPane.showMessageDialog(null, e); }
Comment