maven依赖:
<dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.7.2</version> </dependency>
// 加载驱动 Class.forName("org.sqlite.JDBC"); Connection connection = null; try { String questionContent = null; String options = null; String answers = null; // 获取连接 connection = DriverManager.getConnection("jdbc:sqlite:/Users/root/Downloads/test.db"); Statement statement = connection.createStatement(); // 查询数据 ResultSet resultSet = statement.executeQuery("select * from answers"); while (resultSet.next()){ questionContent = resultSet.getString("question_content"); options = resultSet.getString("options"); answers = resultSet.getString("answers"); System.out.println("questionContent " + questionContent); System.out.println("options " + options); System.out.println("answers " + answers); } // 关闭语句和连接 statement.close(); connection.close(); } catch ( SQLException e) { e.printStackTrace(); }