0
我想显示从mysql的jtable记录 我的表中包含四行。 用户名varchar, 登录时间戳, 注销时间戳, 状态字符。我想要显示记录从mysql的jtable
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();
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));
}
运行程序后,我有这样的错误。
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)
检查你的驱动程序管理器链接 – Hacker
我检查花花公子.....实在不行 –
的Class.forName( “com.mysql.jdbc.Driver”);在Drivermanager类 – Hacker