David Crawshaw wrote:
> 2008/6/20 Lapo Luchini <[EMAIL PROTECTED]>:
>> In the new "one JAR fits all" distribution, is there a way to
>> programmatically know if a native version was found and is in use or
>> if it is running "pure"?
> 
> There is no way yet, but I have been wondering about
> Connection.getClientInfo(). Actually, I'm not really sure what sort of
> stuff is meant to go in there, it looks from the vague JavaDocs that
> it should all be client-mutable.
> 
> Only problem is it came with 1.6, and like all things that came into
> java.sql in 1.6, it is terrible. But it might do the trick.

Uhh, I don't know Java6 very well (yet), as at work we're forced to 
Java5 (and sometimes even 1.4) by the compatibility matrix of some big 
products we need to integrate with…

Another option could be simply to return "0.51-native" or "0.51-pure" 
from conn.getMetaData().getDriverVersion(), which right now is only 
returning "1" actually.

Quick hack:

--- org/sqlite/Conn.java.orig   2008-06-20 12:10:31.000000000 +0200
+++ org/sqlite/Conn.java        2008-06-20 12:44:34.000000000 +0200
@@ -90,6 +90,14 @@
      String url() { return url; }
      String libversion() throws SQLException { return db.libversion(); }
      DB db() { return db; }
+    boolean isUsingNative() {
+        try {
+            Class nativedb = Class.forName("org.sqlite.NativeDB");
+            return nativedb.isInstance(db);
+        } catch (Exception e) {
+            return false;
+        }
+    }

      private void checkOpen() throws SQLException {
          if (db == null)  throw new SQLException("database connection 
closed");
--- org/sqlite/MetaData.java.orig       2008-06-20 12:45:00.000000000 +0200
+++ org/sqlite/MetaData.java    2008-06-20 12:45:03.000000000 +0200
@@ -134,7 +134,7 @@
      public String getDatabaseProductVersion() throws SQLException {
          return conn.libversion(); }
      public String getDriverName() { return "SQLiteJDBC"; }
-    public String getDriverVersion() { return "1"; }
+    public String getDriverVersion() { return conn.isUsingNative() ? 
"native" : "pure"; }
      public String getExtraNameCharacters() { return ""; }
      public String getCatalogSeparator() { return "."; }
      public String getCatalogTerm() { return "catalog"; }

-- 
Lapo Luchini - http://lapo.it/

“C is quirky, flawed, and an enormous success.” (Dennis M. Ritchie)


--~--~---------~--~----~------------~-------~--~----~
Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en
To unsubscribe, send email to [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to