Created
January 12, 2022 13:35
-
-
Save Haoxiqiang/76baa3ba065e8b0204019872f1b8906c to your computer and use it in GitHub Desktop.
load sqlite db from jar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* from my repo:https://github.com/Haoxiqiang/android-quick-reference | |
* In Idea's plugin, org.sqlite.JDBC won't auto registe. | |
* you should call any mehtod which make classloader load org.sqlite.JDBC | |
*/ | |
val classLoader = App.javaClass.classLoader | |
val resource: URL = classLoader.getResource("db/QuickRefDB.db")!! | |
val jdbcURL = "jdbc:sqlite::resource:${resource.toURI()}" | |
// try call org.sqlite.JDBC.<cinit> | |
JDBC.isValidURL(jdbcURL) | |
val driver = JdbcSqliteDriver(jdbcURL) | |
val database = QuickRefDB.invoke(driver) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment