Click here to Skip to main content
15,885,920 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to display the records in jtable from mysql my table contains four rows.
Username varchar,
Login timestamp,
Logout timestamp,
Status char.

i am trying to display username,login time,logout time and status of the username from the table.need a solution thanks in advance

What I have tried:

 public class Secondpage extends javax.swing.JFrame {
   java.sql.Connection conn=null;
   java.sql.PreparedStatement pst = null;
   ResultSet rs = null;
   public Secondpage() throws SQLException{
   initComponents();
   Class.forName("com.mysql.jdbc.Driver"); 
   conn =DriverManager.getConnection("jdbc:mysql://localhost:3306/login?" + 
   "user=root&password=");
   update_table();
   }
   private void update_table(){

   try{
   String sql = "Select * from userlog";
   pst = conn.prepareStatement(sql);
   rs =  pst.executeQuery();
   table.setModel(DbUtils.resultSetToTableModel(rs));
   }<pre>
 
errors:

<pre>java.sql.SQLException:java.sql.Timestamp
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:937)
at com.mysql.jdbc.ByteArrayRow.getTimestampFast(ByteArrayRow.java:130)
com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:5946)
at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:5616)
at com.mysql.jdbc.ResultSetImpl.getObject(ResultSetImpl.java:4594)
at net.proteanit.sql.DbUtils.resultSetToTableModel(DbUtils.java:28)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900