How to use load_extension() function

104 views
Skip to first unread message

Taro L. Saito

unread,
May 27, 2010, 12:37:17 PM5/27/10
to Xerial
Hi,

This is a reminder message about the usage of load_extension() with
sqlite-jdbc:

In order to use load_exension('...') funtion, you have to use
org.sqlite.SQLiteConfig to enable load extension, since
load_extension('..') is disabled in default. Then, pass the result of
config.toProperties() when creating a connection.

Here is a sample code for loading an extension library:

SQLiteConfig config = new SQLiteConfig();
config.enableLoadExtension(true);

Connection connection =
DriverManager.getConnection("jdbc:sqlite:", config.toProperties());
Statement statement = connection.createStatement();
statement.execute("select load_extension('half.sqlext')");
ResultSet rs = statement.executeQuery("select half(10)");
while(rs.next())
{
// read the result set
System.out.println("half = " + rs.getInt(1));
}

I almost forgot about this feature before I got an e-mail for asking
the usage of load_extension(). That is why I am writing this message.
Thanks.

Reply all
Reply to author
Forward
0 new messages