Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use sqlite3_load_extension? #1105

Closed
watersoft123 opened this issue May 1, 2024 · 1 comment
Closed

How do I use sqlite3_load_extension? #1105

watersoft123 opened this issue May 1, 2024 · 1 comment
Labels
question Further information is requested

Comments

@watersoft123
Copy link

watersoft123 commented May 1, 2024

I want to use sqlite-zstd to compress my sqlite db,now I have sqlite_zstd.so file for Android. how do I use "sqlite3_load_extension" to load sqlite_zstd.so extension? I'm not very familiar with Java. Could you provide an example?Thank you very much.
Below is the Java code I am using; I am not very familiar with Java, but have not been able to successfully load the extension, so there may be some errors.

//load an extension
private void loadExtension() {
SQLiteConfig config = new SQLiteConfig();
config.enableLoadExtension(true);
try {
if (connection != null) {
Statement stmt = connection.createStatement();
stmt.execute("SELECT load_extension('libsqlite_zstd')");
System.out.println("Extension '" + extensionName + "' loaded successfully.");
} else {
System.out.println("No connection to SQLite database. Cannot load extension.");
}
} catch (SQLException e) {
System.out.println("Error loading extension '" + extensionName + "': " + e.getMessage());
}
}

@gotson gotson added the question Further information is requested label May 2, 2024
@watersoft123
Copy link
Author

I want to use sqlite-zstd to compress my sqlite db,now I have sqlite_zstd.so file for Android. how do I use "sqlite3_load_extension" to load sqlite_zstd.so extension? I'm not very familiar with Java. Could you provide an example?Thank you very much. Below is the Java code I am using; I am not very familiar with Java, but have not been able to successfully load the extension, so there may be some errors.

//load an extension private void loadExtension() { SQLiteConfig config = new SQLiteConfig(); config.enableLoadExtension(true); try { if (connection != null) { Statement stmt = connection.createStatement(); stmt.execute("SELECT load_extension('libsqlite_zstd')"); System.out.println("Extension '" + extensionName + "' loaded successfully."); } else { System.out.println("No connection to SQLite database. Cannot load extension."); } } catch (SQLException e) { System.out.println("Error loading extension '" + extensionName + "': " + e.getMessage()); } }

The issue has been resolved; it was a problem with the path of the so file.

@gotson gotson closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants