You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2013/04/08 23:48:07 UTC

svn commit: r1465804 - in /jena/Experimental/jena-jdbc: jena-jdbc-core/src/main/java/org/apache/jena/jdbc/ jena-jdbc-core/src/test/java/org/apache/jena/jdbc/ jena-jdbc-core/src/test/java/org/apache/jena/jdbc/preprocessing/ jena-jdbc-driver-mem/src/main...

Author: rvesse
Date: Mon Apr  8 21:48:06 2013
New Revision: 1465804

URL: http://svn.apache.org/r1465804
Log:
Add code to load and register pre-processors at connection creation time

Added:
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/preprocessing/
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/preprocessing/Echo.java
Modified:
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JenaDriver.java
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/AbstractJenaDriverTests.java
    jena/Experimental/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java
    jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
    jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JenaDriver.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JenaDriver.java?rev=1465804&r1=1465803&r2=1465804&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JenaDriver.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JenaDriver.java Mon Apr  8 21:48:06 2013
@@ -29,6 +29,7 @@ import java.util.Map.Entry;
 import java.util.Properties;
 
 import org.apache.jena.jdbc.connections.JenaConnection;
+import org.apache.jena.jdbc.preprocessing.CommandPreProcessor;
 
 /**
  * <p>
@@ -71,7 +72,7 @@ import org.apache.jena.jdbc.connections.
  * drivers and this is the {@code jdbc-compatibility} parameter. To avoid typos
  * when creating URLs programmatically a constant (
  * {@link #PARAM_JDBC_COMPATIBILITY}) is provided which contains the parameter
- * name exactly as the code expects it.  This parameter provides an integer value
+ * name exactly as the code expects it. This parameter provides an integer value
  * in the range 1-9 which denotes how compatible the driver should attempt to
  * be, see {@link JdbcCompatibility} for discussion on the meaning of
  * compatibility levels. When not set the {@link JdbcCompatibility#DEFAULT}
@@ -93,6 +94,20 @@ public abstract class JenaDriver impleme
      */
     public static final String PARAM_JDBC_COMPATIBILITY = "jdbc-compatibility";
 
+    /**
+     * Constant for the driver parameter used to set class names of
+     * {@link CommandPreProcessor} implementations to use with returned
+     * connections.
+     * <p>
+     * This parameter may be specified multiple times and pre-processors will be
+     * registered (and thus applied) in the order specified. If any
+     * pre-processors are passed as part of the {@link Properties} object rather
+     * than in the connection URL then these will be registered (and thus
+     * applied) prior to those specified in the connection URL.
+     * </p>
+     */
+    public static final String PARAM_PRE_PROCESSOR = "pre-processor";
+
     private int majorVer, minorVer;
     private String implPrefix;
 
@@ -201,18 +216,126 @@ public abstract class JenaDriver impleme
         int compatibilityLevel = JdbcCompatibility.parseLevel(ps.get(PARAM_JDBC_COMPATIBILITY));
 
         // Try to create the connection
-        return this.connect(ps, compatibilityLevel);
+        JenaConnection conn = null;
+        boolean abort = false;
+        try {
+            // Attempt connection
+            conn = this.connect(ps, compatibilityLevel);
+
+            // Attempt registration of command pre-processors
+            Object ppObj = ps.get(PARAM_PRE_PROCESSOR);
+            List<String> preProcessors;
+            if (ppObj == null) {
+                // Nothing to register
+                return conn;
+            } else if (ppObj instanceof String) {
+                // Single instance to try and register
+                preProcessors = new ArrayList<String>();
+                preProcessors.add(ppObj.toString());
+            } else if (ppObj instanceof List<?>) {
+                // Multiple instances to try and register
+                preProcessors = (List<String>) ppObj;
+            } else {
+                // Parameter set to some unexpected type
+                throw new SQLException("Parameter " + PARAM_PRE_PROCESSOR + " was set to a value of unexpected type "
+                        + ppObj.getClass().getCanonicalName()
+                        + ", expected either a String or List<String> as the parameter value");
+            }
+
+            // Try and create each pre-processor
+            for (String ppClassName : preProcessors) {
+                // Ignore null values
+                if (ppClassName == null) continue;
+                
+                try {
+                    Class<?> c = Class.forName(ppClassName);
+                    Object i = c.newInstance();
+
+                    if (i instanceof CommandPreProcessor) {
+                        // If it implements the right interface register it
+                        conn.addPreProcessor((CommandPreProcessor) i);
+                    } else {
+                        // Otherwise throw an error
+                        throw new SQLException(
+                                "Parameter "
+                                        + PARAM_PRE_PROCESSOR
+                                        + " includes the value "
+                                        + ppClassName
+                                        + " which references a class that does not implement the expected CommandPreProcessor interface, please ensure that the class name is corect and that the class implements the required interface");
+                    }
+                } catch (ClassNotFoundException e) {
+                    // Unable to find the referenced class
+                    throw new SQLException(
+                            "Parameter "
+                                    + PARAM_PRE_PROCESSOR
+                                    + " includes the value "
+                                    + ppClassName
+                                    + " which references a class that could not be found, please ensure that the class name is correct and the JAR containing this class is on your class path",
+                            e);
+                } catch (InstantiationException e) {
+                    // Unable to instantiate the referenced class
+                    throw new SQLException(
+                            "Parameter "
+                                    + PARAM_PRE_PROCESSOR
+                                    + " includes the value "
+                                    + ppClassName
+                                    + " which references a class that could not be sucessfully instantiated, this class must have an unparameterized constructor to be usable with this parameter.  If this is not possible try calling addPreProcessor() on the returned JenaConnection instead",
+                            e);
+                } catch (IllegalAccessException e) {
+                    // Referenced class is not accessible
+                    throw new SQLException(
+                            "Parameter "
+                                    + PARAM_PRE_PROCESSOR
+                                    + " includes the value "
+                                    + ppClassName
+                                    + " which references a class that could not be sucessfully instantiated, this class must have a publicly accessible unparameterized constructor to be usable with this parameter.  If this is not possible try calling addPreProcessor() on the returned JenaConnection instead",
+                            e);
+                } catch (Exception e) {
+                    // Unexpected error
+                    throw new SQLException(
+                            "Parameter "
+                                    + PARAM_PRE_PROCESSOR
+                                    + " includes the value "
+                                    + ppClassName
+                                    + " which caused an unexpected exception when trying to instantiate it, see the inner exception for details",
+                            e);
+                }
+            }
+            
+            // All pre-processors successfully registered, return the connection
+            return conn;
+        } catch (SQLException e) {
+            abort = true;
+            throw e;
+        } catch (Exception e) {
+            abort = true;
+            throw new SQLException("Unexpected exception while establishing a connection, see inner exception for details", e);
+        } finally {
+            // If something has gone badly wrong close the connection
+            if (abort && conn != null) {
+                conn.close();
+            }
+        }
     }
 
     /**
      * Gets whether a parameter is allowed to have multiple values
+     * <p>
+     * If you override this method in your driver implementation you should make
+     * sure to include a call back to this method as otherwise you may cause
+     * incorrect driver instantiation.
+     * </p>
      * 
      * @param key
      *            Key
      * @return True if multiple values are allowed, false otherwise
      */
     protected boolean allowsMultipleValues(String key) {
-        return false;
+        if (PARAM_PRE_PROCESSOR.equals(key)) {
+            return true;
+        } else {
+            return false;
+        }
     }
 
     /**
@@ -235,7 +358,7 @@ public abstract class JenaDriver impleme
      * @throws SQLException
      *             Thrown if a connection cannot be created for any reason
      */
-    protected abstract Connection connect(Properties props, int compatabilityLevel) throws SQLException;
+    protected abstract JenaConnection connect(Properties props, int compatabilityLevel) throws SQLException;
 
     @Override
     public int getMajorVersion() {

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/AbstractJenaDriverTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/AbstractJenaDriverTests.java?rev=1465804&r1=1465803&r2=1465804&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/AbstractJenaDriverTests.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/AbstractJenaDriverTests.java Mon Apr  8 21:48:06 2013
@@ -20,7 +20,11 @@ package org.apache.jena.jdbc;
 
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.Iterator;
 
+import org.apache.jena.jdbc.connections.JenaConnection;
+import org.apache.jena.jdbc.preprocessing.CommandPreProcessor;
+import org.apache.jena.jdbc.preprocessing.Echo;
 import org.apache.log4j.BasicConfigurator;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
@@ -28,6 +32,7 @@ import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Test;
 
+import com.hp.hpl.jena.graph.Node;
 import com.hp.hpl.jena.query.ARQ;
 
 /**
@@ -122,6 +127,132 @@ public abstract class AbstractJenaDriver
         conn.close();
         Assert.assertTrue(conn.isClosed());
     }
+        
+    /**
+     * Tests using a driver to create a connection with its own URLs plus the standard JDBC compatibility parameter
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_connect_02() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        url = url + "&" + JenaDriver.PARAM_JDBC_COMPATIBILITY + "=" + JdbcCompatibility.LOW;
+        JenaDriver driver = this.getDriver();
+
+        JenaConnection conn = (JenaConnection)driver.connect(url, null);
+        Assert.assertFalse(conn.isClosed());
+        Assert.assertEquals(JdbcCompatibility.LOW, conn.getJdbcCompatibilityLevel());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Tests using a driver to create a connection with its own URLs plus the standard JDBC compatibility parameter
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_connect_03() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        url = url + "&" + JenaDriver.PARAM_JDBC_COMPATIBILITY + "=" + Integer.MIN_VALUE;
+        JenaDriver driver = this.getDriver();
+
+        JenaConnection conn = (JenaConnection)driver.connect(url, null);
+        Assert.assertFalse(conn.isClosed());
+        Assert.assertEquals(JdbcCompatibility.LOW, conn.getJdbcCompatibilityLevel());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Tests using a driver to create a connection with its own URLs plus the standard JDBC compatibility parameter
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_connect_04() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        url = url + "&" + JenaDriver.PARAM_JDBC_COMPATIBILITY + "=" + JdbcCompatibility.HIGH;
+        JenaDriver driver = this.getDriver();
+
+        JenaConnection conn = (JenaConnection)driver.connect(url, null);
+        Assert.assertFalse(conn.isClosed());
+        Assert.assertEquals(JdbcCompatibility.HIGH, conn.getJdbcCompatibilityLevel());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Tests using a driver to create a connection with its own URLs plus the standard JDBC compatibility parameter
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_connect_05() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        url = url + "&" + JenaDriver.PARAM_JDBC_COMPATIBILITY + "=" + Integer.MAX_VALUE;
+        JenaDriver driver = this.getDriver();
+
+        JenaConnection conn = (JenaConnection)driver.connect(url, null);
+        Assert.assertFalse(conn.isClosed());
+        Assert.assertEquals(JdbcCompatibility.HIGH, conn.getJdbcCompatibilityLevel());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Tests using a driver to create a connection with its own URLs plus the standard pre-processor parameter
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_connect_06() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName();
+        JenaDriver driver = this.getDriver();
+
+        JenaConnection conn = (JenaConnection)driver.connect(url, null);
+        Assert.assertFalse(conn.isClosed());
+        Iterator<CommandPreProcessor> iter = conn.getPreProcessors();
+        Assert.assertTrue(iter.hasNext());
+        iter.next();
+        Assert.assertFalse(iter.hasNext());
+        
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Tests using a driver to create a connection with its own URLs plus the standard pre-processor parameter
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_connect_07() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        // We can register it twice if we want
+        url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName();
+        url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName();
+        JenaDriver driver = this.getDriver();
+
+        JenaConnection conn = (JenaConnection)driver.connect(url, null);
+        Assert.assertFalse(conn.isClosed());
+        Iterator<CommandPreProcessor> iter = conn.getPreProcessors();
+        Assert.assertTrue(iter.hasNext());
+        iter.next();
+        Assert.assertTrue(iter.hasNext());
+        iter.next();
+        Assert.assertFalse(iter.hasNext());
+        
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
     
     /**
      * Tests using a driver to create a connection with its own URLs which are known to be bad
@@ -129,11 +260,43 @@ public abstract class AbstractJenaDriver
      * @throws SQLException
      */
     @Test(expected=SQLException.class)
-    public void driver_connect_02() throws SQLException {
+    public void driver_connect_bad_01() throws SQLException {
         String url = this.getBadConnectionUrl();
         Assume.assumeNotNull(url);
         JenaDriver driver = this.getDriver();
 
         driver.connect(url, null);
     }
+    
+    /**
+     * Tests using a driver to create a connection with its own URLs plus the standard pre-processor parameter but setting the pre-processor to a value that creates an error
+     * 
+     * @throws SQLException
+     */
+    @Test(expected=SQLException.class)
+    public void driver_connect_bad_02() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        // Try to use a class that doesn't exist 
+        url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=NoSuchClass";
+        
+        JenaDriver driver = this.getDriver();
+        driver.connect(url, null);
+    }
+    
+    /**
+     * Tests using a driver to create a connection with its own URLs plus the standard pre-processor parameter but setting the pre-processor to a value that creates an error
+     * 
+     * @throws SQLException
+     */
+    @Test(expected=SQLException.class)
+    public void driver_connect_bad_03() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        // Try to use a class that exists but isn't a CommandPreProcessor 
+        url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Node.class.getCanonicalName();
+        
+        JenaDriver driver = this.getDriver();
+        driver.connect(url, null);
+    }
 }

Added: jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/preprocessing/Echo.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/preprocessing/Echo.java?rev=1465804&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/preprocessing/Echo.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/preprocessing/Echo.java Mon Apr  8 21:48:06 2013
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.jdbc.preprocessing;
+
+import java.sql.SQLException;
+
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.update.UpdateRequest;
+
+/**
+ * A trivial command pre-processor that simply returns the input
+ *
+ */
+public class Echo implements CommandPreProcessor {
+
+    @Override
+    public String preProcessCommandText(String text) throws SQLException {
+        return text;
+    }
+
+    @Override
+    public Query preProcessQuery(Query q) throws SQLException {
+        return q;
+    }
+
+    @Override
+    public UpdateRequest preProcessUpdate(UpdateRequest u) throws SQLException {
+        return u;
+    }
+
+}

Modified: jena/Experimental/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java?rev=1465804&r1=1465803&r2=1465804&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-mem/src/main/java/org/apache/jena/jdbc/mem/MemDriver.java Mon Apr  8 21:48:06 2013
@@ -18,7 +18,6 @@
 
 package org.apache.jena.jdbc.mem;
 
-import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Properties;
@@ -92,7 +91,7 @@ public class MemDriver extends JenaDrive
     }
 
     @Override
-    protected Connection connect(Properties props, int compatibilityLevel) throws SQLException {
+    protected JenaConnection connect(Properties props, int compatibilityLevel) throws SQLException {
         Object dsObj = props.get(PARAM_DATASET);
         String empty = props.getProperty(PARAM_EMPTY);
         if (empty != null) empty = empty.toLowerCase();
@@ -101,18 +100,18 @@ public class MemDriver extends JenaDrive
         if (dsObj != null) {
             if (dsObj instanceof Dataset) {
                 // Dataset provided directly
-                return (Connection) new MemConnection((Dataset)dsObj, JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
+                return new MemConnection((Dataset)dsObj, JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
             } else {
                 try {
                     Dataset ds = DatasetFactory.createMem();
                     RDFDataMgr.read(ds, dsObj.toString());
-                    return (Connection) new MemConnection(ds, JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
+                    return new MemConnection(ds, JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
                 } catch (Exception e) {
                     throw new SQLException("Error occurred while reading from the specified RDF dataset file - " + dsObj.toString(), e);
                 }
             }
         } else if ("true".equals(empty)) {
-            return (Connection) new MemConnection(DatasetFactory.createMem(), JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
+            return new MemConnection(DatasetFactory.createMem(), JenaConnection.DEFAULT_HOLDABILITY, JenaConnection.DEFAULT_AUTO_COMMIT, JenaConnection.DEFAULT_ISOLATION_LEVEL, compatibilityLevel);
         } else {
             throw new SQLException("Insufficient parameters to create a Jena JDBC in-memory connection, please supply a Dataset file/instance via the " + PARAM_DATASET + " parameter or supply " + PARAM_EMPTY + "=true to connect to a new empty dataset");
         }

Modified: jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java?rev=1465804&r1=1465803&r2=1465804&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java Mon Apr  8 21:48:06 2013
@@ -18,7 +18,6 @@
 
 package org.apache.jena.jdbc.remote;
 
-import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Properties;
@@ -92,7 +91,7 @@ public class RemoteEndpointDriver extend
     }
 
     @Override
-    protected Connection connect(Properties props, int compatibilityLevel) throws SQLException {
+    protected JenaConnection connect(Properties props, int compatibilityLevel) throws SQLException {
         String queryEndpoint = props.getProperty(PARAM_QUERY_ENDPOINT);
         String updateEndpoint = props.getProperty(PARAM_UPDATE_ENDPOINT);
 

Modified: jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java?rev=1465804&r1=1465803&r2=1465804&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java Mon Apr  8 21:48:06 2013
@@ -19,7 +19,6 @@
 package org.apache.jena.jdbc.tdb;
 
 import java.io.File;
-import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Properties;
 
@@ -94,7 +93,7 @@ public class TDBDriver extends JenaDrive
     }
 
     @Override
-    protected Connection connect(Properties props, int compatibilityLevel) throws SQLException {
+    protected JenaConnection connect(Properties props, int compatibilityLevel) throws SQLException {
         String location = props.getProperty(PARAM_LOCATION);
         if (location == null)
             throw new SQLException("Required connection parameter " + PARAM_LOCATION
@@ -132,8 +131,8 @@ public class TDBDriver extends JenaDrive
         try {
             Dataset tdb = useMem ? TDBFactory.createDataset() : TDBFactory.createDataset(location);
 
-            // Return a JenaJdbcDatasetConnection for the TDB dataset
-            return (Connection) new TDBConnection(tdb, JenaConnection.DEFAULT_HOLDABILITY, true, compatibilityLevel);
+            // Return a new connection for the TDB dataset
+            return new TDBConnection(tdb, JenaConnection.DEFAULT_HOLDABILITY, true, compatibilityLevel);
         } catch (SQLException e) {
             throw e;
         } catch (Exception e) {