【发布时间】:2017-05-13 13:56:03
【问题描述】:
我的程序从 Access 数据库中获取几列,并在 JTable 中显示数据。它工作正常,但我需要在数据显示时进行一些更改。就像,尽管在 Access 数据库中以 dd-MM-yyyy 的形式存储数据,但它在检索时以 yyyy-MM-dd tt:tt:tt 格式显示。我需要在表格中以dd-MM-yyyy的形式显示。此日期字段在表的第一列中表示为for_date。
sql = "Select for_date as FOR_DATE,outage_time as OUTAGE_TIME,stat_detail as STATION_DETAILS from " + table_sel + " where for_date='" + date1 + "' and stat_detail ='" + combo_sel + "'";
Connection con = null;
Statement st = null;
ResultSet rs = null;
PreparedStatement pst = null;
String dbURL = "jdbc:ucanaccess://C:\\Users\\Dell_PC\\Documents\\SYSTEM_OUTAGE_REPORT.accdb";
con = DriverManager.getConnection(dbURL);
st = con.createStatement();
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
con.close();
【问题讨论】:
标签: java mysql swing date ms-access