我在Mac上创建了一个机票系统,我创建了一个SQLite数据库以用于随机飞行时间,单击按钮后,该随机数据将显示在Jtable上,但是当我进入该数据库所在的文件夹时,当我在文件中清楚看到该数据库时,找不到该数据库。
我的桌子做得正确
(这是我的SQLite连接类)
package travelling_Ticket;
import java.sql.*;
import javax.swing.*;
public class sqliteConnection {
Connection conn = null;
public static Connection dbConnector(){
try {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\cjt1496\\sqlite\\flightTimes.db");
return conn;
}catch ( Exception e ) {
JOptionPane.showMessageDialog(null, e);
}
System.out.println("Opened database successfully");
return null;
}
}
(这里是用来显示Jtable内部飞行时间数据库表的按钮,编译后显示的错误是找不到表flightTimes)
JButton btnLoadFlights = new JButton("Load Flight Times");
btnLoadFlights.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
String query = "select * from flightTimes";
PreparedStatement pst = connection.prepareStatement(query);
ResultSet rs = pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
}catch (Exception e1){
e1.printStackTrace();
}
}
});