Java JDBCSQLite不返回任何行

Java JDBCSQLite不返回任何行,java,sqlite,jdbc,Java,Sqlite,Jdbc,运行SQLite Studio时,我的查询返回正确的结果,但在控制台上我的输出是: 连接成功 (行计数+行数。由于某些原因,getRow()未在此处打印) 共有0条记录。 在Bookings表中是否有记录,是否连接到正确的数据库?将e.printStackTrace()放在空的catch块中。是的,如上所述,我正在使用SQLite Studio查看我的数据库并测试我的查询。我可以在org.sqlite.Conn.commit(Conn.java:342)的there.java.sql.SQLEx

运行SQLite Studio时,我的查询返回正确的结果,但在控制台上我的输出是:

连接成功
(行计数+行数。由于某些原因,getRow()未在此处打印)
共有0条记录。

在Bookings表中是否有记录,是否连接到正确的数据库?将
e.printStackTrace()
放在空的catch块中。是的,如上所述,我正在使用SQLite Studio查看我的数据库并测试我的查询。我可以在org.sqlite.Conn.commit(Conn.java:342)的there.java.sql.SQLException:database in auto commit mode上看到我返回的行。这是stacktraceSo,在auto commit mode中,不能使用
commit
。并且永远不要将
catch
块留空,除非您绝对确定不会抛出异常。
public ArrayList<Booking> getAllBookings(){
    ArrayList<Booking> list = new ArrayList<Booking>();
    int rowCount = 0;
    try {           
        stmt = connection.createStatement();     
        String sql = "SELECT * FROM Bookings";          
        ResultSet rows = stmt.executeQuery(sql); 
        rows.last();
        System.out.println("Row Count "+rows.getRow());
        rows.beforeFirst();
        connection.commit();           

        while (rows.next()){
            Booking b = new Booking();
            otherStuff();
            list.add(b);
            rowCount++;
        }
        stmt.close();
        rows.close();
    } catch (Exception e) {

    }     

    System.out.println("There were " +rowCount + " records.");
    return list;
}
public static Connection dbConnect(){
 try {     
     Class.forName("org.sqlite.JDBC");
     Connection connection = DriverManager.getConnection("jdbc:sqlite:D:/test/test_db.sqlite3");
     System.out.println("Connection Succesful");
     return connection;
 } catch (Exception e) {
     System.out.println(e);
     return null;
 } }