補充:上面每個方法都改成 try-with-resources,Statement/PreparedStatement/ResultSet/Connection 會在區塊結束時自動關閉,就算中途丟例外也不會漏。另外在 JDK 24 之後執行 sqlite-jdbc 會看到 restricted method 警告,加上 --enable-native-access=ALL-UNNAMED 即可消除(不影響執行)。
SQLite is a lightweight database system that can be used without installation and can be easily embedded in the system.
SQLite is written in C language, and it can cross Linux and Windows platforms. You can use JDBC to connect to SQLite for Java access and operation.
On JDBC connection to SQLite, it is roughly divided into two ways. One is to connect the data by Pure-Java, and the other is to call the function library written in C directly from Java. The method should be faster, but in platforms where a suitable C function library cannot be found, the Pure-Java version can be used.
SQLite JDBC github , This Example support create Table、drop Table、Query table、insert、delete and Update…
https://github.com/catyku/SQLiteExample
閱讀全文