private void loadFromDirectory(final File libPath) { // configure less verbose logging Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.WARNING); SQLite.setLibraryPath(libPath.getAbsolutePath()); try { log("SQLite version: library " + SQLite.getLibraryVersion() + " / core " + SQLite.getSQLiteVersion()); } catch (SQLiteException e) { throw new RuntimeException(e); } loaded = true; }
Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.SEVERE); String v = getLibraryVersion(); if (v == null) v = "(UNKNOWN VERSION)"; System.out.println("sqlite4java " + v); } else { try { System.out.println("SQLite " + getSQLiteVersion()); System.out.println("Compile-time options: " + getSQLiteCompileOptions()); } catch (SQLiteException e) { e.printStackTrace();
/** * Checks if the given SQL is complete. * * @param sql the SQL * @return true if sql is a complete statement * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/complete.html">sqlite3_complete</a> */ public static boolean isComplete(String sql) throws SQLiteException { loadLibrary(); return _SQLiteSwigged.sqlite3_complete(sql) != 0; }
private static List<String> collectLibraryNames(String versionSuffix, String os, String arch) { List<String> baseSuffixes = collectBaseLibraryNames(os, arch); ArrayList<String> r = new ArrayList<String>(24); String[] configurationSuffixes = SQLite.isDebugBinaryPreferred() ? DEBUG_SUFFIXES : RELEASE_SUFFIXES; if (versionSuffix != null) { for (String configurationSuffix : configurationSuffixes) { for (String baseSuffix : baseSuffixes) { r.add(baseSuffix + configurationSuffix + versionSuffix); } } } for (String configurationSuffix : configurationSuffixes) { for (String baseSuffix : baseSuffixes) { r.add(baseSuffix + configurationSuffix); } } return r; }
/** * Sets the "soft limit" on the amount of memory allocated before SQLite starts trying to free some * memory before allocating more memory. * * @param limit the number of bytes to set the soft memory limit to * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/soft_heap_limit.html">sqlite3_soft_heap_limit</a> */ public static void setSoftHeapLimit(int limit) throws SQLiteException { loadLibrary(); _SQLiteSwigged.sqlite3_soft_heap_limit64(limit); }
private void loadFromDirectory(final File libPath) { // configure less verbose logging Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.WARNING); SQLite.setLibraryPath(libPath.getAbsolutePath()); try { log("SQLite version: library " + SQLite.getLibraryVersion() + " / core " + SQLite.getSQLiteVersion()); } catch (SQLiteException e) { throw new RuntimeException(e); } loaded = true; }
/** * Gets the numeric representation of the SQLite version. * * @return a number representing the version; example: version "3.6.23.1" is represented as 3006023. * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/libversion.html">sqlite3_version</a> */ public static int getSQLiteVersionNumber() throws SQLiteException { loadLibrary(); return _SQLiteSwigged.sqlite3_libversion_number(); }
private void loadFromDirectory(final File libPath) { // configure less verbose logging Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.WARNING); SQLite.setLibraryPath(libPath.getAbsolutePath()); try { log("SQLite version: library " + SQLite.getLibraryVersion() + " / core " + SQLite.getSQLiteVersion()); } catch (SQLiteException e) { throw new RuntimeException(e); } loaded = true; }
/** * Requests SQLite to try to release some memory from its heap. This could be called to clear cache. * * @param bytes the number of bytes requested to be released * @return the number of bytes actually released * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/release_memory.html">sqlite3_release_memory</a> */ public static int releaseMemory(int bytes) throws SQLiteException { loadLibrary(); return _SQLiteSwigged.sqlite3_release_memory(bytes); }
private void loadFromDirectory(final File libPath) { // configure less verbose logging Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.WARNING); SQLite.setLibraryPath(libPath.getAbsolutePath()); try { log("SQLite version: library " + SQLite.getLibraryVersion() + " / core " + SQLite.getSQLiteVersion()); } catch (SQLiteException e) { throw new RuntimeException(e); } loaded = true; }
/** * Gets the version of SQLite database. * * @return SQLite version * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/libversion.html">sqlite3_libversion</a> */ public static String getSQLiteVersion() throws SQLiteException { loadLibrary(); return _SQLiteSwigged.sqlite3_libversion(); }
private void loadFromDirectory(final File libPath) { // configure less verbose logging Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.WARNING); SQLite.setLibraryPath(libPath.getAbsolutePath()); try { log("SQLite version: library " + SQLite.getLibraryVersion() + " / core " + SQLite.getSQLiteVersion()); } catch (SQLiteException e) { throw new RuntimeException(e); } loaded = true; }
/** * Sets the "soft limit" on the amount of memory allocated before SQLite starts trying to free some * memory before allocating more memory. * * @param limit the number of bytes to set the soft memory limit to * @return size of the soft heap limit prior to the call * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/soft_heap_limit64.html">sqlite3_soft_heap_limit64</a> */ public static long softHeapLimit(long limit) throws SQLiteException { loadLibrary(); return _SQLiteSwigged.sqlite3_soft_heap_limit64(limit); }
/** * Returns the maximum amount of memory that was used by SQLite since the last time the highwater * was reset. * * @param reset if true, the highwatermark is reset after this call * @return the maximum number of bytes ever used by SQLite library since the start of the application * or the last reset of the highwatermark. * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/memory_highwater.html">sqlite3_memory_highwater</a> */ public static long getMemoryHighwater(boolean reset) throws SQLiteException { loadLibrary(); return _SQLiteSwigged.sqlite3_memory_highwater(reset ? 1 : 0); }
/** * Gets the amount of memory currently used by SQLite library. The returned value shows the amount of non-heap * "native" memory taken up by SQLite caches and anything else allocated with sqlite3_malloc. * <p/> * This value does not include any heap or other JVM-allocated memory taken up by sqlite4java objects and classes. * * @return the number of bytes used by SQLite library in this process (for all connections) * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/memory_highwater.html">sqlite3_memory_used</a> */ public static long getMemoryUsed() throws SQLiteException { loadLibrary(); return _SQLiteSwigged.sqlite3_memory_used(); }
/** * Checks if SQLite has been compiled with the THREADSAFE option. * <p/> * * @return true if SQLite has been compiled with THREADSAFE option * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/threadsafe.html">sqlite3_threadsafe</a> */ public static boolean isThreadSafe() throws SQLiteException { Boolean cachedResult = threadSafe; if (cachedResult != null) return cachedResult; loadLibrary(); boolean r = _SQLiteSwigged.sqlite3_threadsafe() != 0; threadSafe = r; return r; }
/** * Gets the compile-time options used to compile the used library. * * @return a string with all compile-time options delimited by a space * @throws SQLiteException if native library cannot be loaded * @see <a href="http://www.sqlite.org/c3ref/compileoption_get.html">sqlite3_compileoption_get</a> */ public static String getSQLiteCompileOptions() throws SQLiteException { loadLibrary(); StringBuilder b = new StringBuilder(); int i = 0; while (true) { String option = _SQLiteSwigged.sqlite3_compileoption_get(i++); if (option == null || option.length() == 0) break; if (b.length() > 0) b.append(' '); b.append(option); } return b.toString(); }
/** * Sets whether <a href="http://www.sqlite.org/sharedcache.html">shared cache mode</a> will be used * for the connections that are opened after this call. All existing connections are not affected. * <p/> * <strong>sqlite4java</strong> explicitly disables shared cache on start. This is also the default declared by SQLite, * but it may change in the future, so <strong>sqlite4java</strong> enforces consistency. * * @param enabled if true, the following calls to {@link SQLiteConnection#open} will used shared-cache mode * @throws SQLiteException if native library cannot be loaded, or if call returns an error * @see <a href="http://www.sqlite.org/c3ref/enable_shared_cache.html">sqlite3_enable_shared_cache</a> */ public static void setSharedCache(boolean enabled) throws SQLiteException { loadLibrary(); int rc = _SQLiteSwigged.sqlite3_enable_shared_cache(enabled ? 1 : 0); if (rc != SQLiteConstants.SQLITE_OK) throw new SQLiteException(rc, "SQLite: cannot set shared_cache to " + enabled); }
private void open0(int flags) throws SQLiteException { SQLite.loadLibrary(); if (Internal.isFineLogging()) Internal.logFine(this, "opening (0x" + Integer.toHexString(flags).toUpperCase(Locale.US) + ")");