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/04 00:01:28 UTC

svn commit: r1464215 [2/3] - in /jena/Experimental/jena-jdbc: jena-jdbc-core/src/main/java/org/apache/jena/jdbc/ jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/ jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/ jena-jdbc-core/s...

Added: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java?rev=1464215&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java Wed Apr  3 22:01:26 2013
@@ -0,0 +1,962 @@
+/**
+ * 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.results;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+
+import org.apache.jena.jdbc.utils.JenaJdbcNodeUtils;
+
+import com.hp.hpl.jena.graph.Node;
+
+/**
+ * Abstract implementation of a JDBC Result Set which makes all update methods
+ * throw {@link SQLFeatureNotSupportedException}
+ * 
+ */
+public abstract class JenaResultSet implements ResultSet {
+
+    private static final int DEFAULT_HOLDABILITY = ResultSet.CLOSE_CURSORS_AT_COMMIT;
+    
+    private SQLWarning warnings;
+    private Statement statement;
+    private boolean wasNull = false;
+    private int holdability = DEFAULT_HOLDABILITY;
+
+    /**
+     * Creates a new result set
+     * 
+     * @param statement
+     *            Statement that originated the result set
+     * @throws SQLException
+     *             Thrown if the arguments are invalid
+     */
+    public JenaResultSet(Statement statement) throws SQLException {
+        if (statement == null)
+            throw new SQLException("Statement for a Result Set cannot be null");
+        this.statement = statement;
+    }
+
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public void cancelRowUpdates() throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public final void clearWarnings() throws SQLException {
+        this.warnings = null;
+    }
+
+    public void deleteRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+    
+    public final int getHoldability() throws SQLException {
+        return this.holdability;
+    }
+    
+    public final int getConcurrency() throws SQLException {
+        return ResultSet.CONCUR_READ_ONLY;
+    }
+    
+    public abstract ResultSetMetaData getMetaData() throws SQLException;
+
+    // Get Methods for things we do support
+
+    /**
+     * Helper method which retrieves the Node for the given index of the current
+     * row
+     * 
+     * @param columnIndex
+     *            Column Index
+     * @return Node if there is a value, null if no value for the column
+     * @throws SQLException
+     *             Should be thrown if there is no current row, the column index
+     *             is invalid or the result set is closed
+     */
+    protected Node getNode(int columnIndex) throws SQLException {
+        return this.getNode(this.findColumnLabel(columnIndex));
+    }
+
+    /**
+     * Helper method which derived classes must implement to map a column index
+     * to a column label
+     * 
+     * @param columnIndex
+     *            Column Index
+     * @return Column Label
+     * @throws SQLException
+     *             Should be thrown if the column index is invalid
+     */
+    protected abstract String findColumnLabel(int columnIndex) throws SQLException;
+
+    /**
+     * Helper method which derived classes must implement to retrieve the Node
+     * for the given column of the current row
+     * 
+     * @param columnLabel
+     *            Column Label
+     * @return Node if there is a value, null if no value for the column
+     * @throws SQLException
+     *             Should be thrown if there is no current row, the column label
+     *             is invalid or the result set is closed
+     */
+    protected abstract Node getNode(String columnLabel) throws SQLException;
+
+    public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+        return this.getBigDecimal(this.findColumnLabel(columnIndex));
+    }
+
+    public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return null;
+        } else {
+            // Try to marshal into a decimal
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toDecimal(n);
+        }
+    }
+
+    public boolean getBoolean(int columnIndex) throws SQLException {
+        return this.getBoolean(this.findColumnLabel(columnIndex));
+    }
+
+    public boolean getBoolean(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return false;
+        } else {
+            // Try to marshal into a boolean
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toBoolean(n);
+        }
+    }
+
+    public byte getByte(int columnIndex) throws SQLException {
+        return this.getByte(this.findColumnLabel(columnIndex));
+    }
+
+    public byte getByte(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return 0;
+        } else {
+            // Try to marshal into a byte
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toByte(n);
+        }
+    }
+
+    public Date getDate(int columnIndex) throws SQLException {
+        return this.getDate(this.findColumnLabel(columnIndex));
+    }
+
+    public Date getDate(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return null;
+        } else {
+            // Try to marshal into a date
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toDate(n);
+        }
+    }
+
+    public double getDouble(int columnIndex) throws SQLException {
+        return this.getDouble(this.findColumnLabel(columnIndex));
+    }
+
+    public double getDouble(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return 0;
+        } else {
+            // Try to marshal into a date
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toDouble(n);
+        }
+    }
+
+    public float getFloat(int columnIndex) throws SQLException {
+        return this.getFloat(this.findColumnLabel(columnIndex));
+    }
+
+    public float getFloat(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return 0;
+        } else {
+            // Try to marshal into a date
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toFloat(n);
+        }
+    }
+
+    public int getInt(int columnIndex) throws SQLException {
+        return this.getInt(this.findColumnLabel(columnIndex));
+    }
+
+    public int getInt(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return 0;
+        } else {
+            // Try to marshal into an integer
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toInt(n);
+        }
+    }
+
+    public long getLong(int columnIndex) throws SQLException {
+        return this.getLong(this.findColumnLabel(columnIndex));
+    }
+
+    public long getLong(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return 0;
+        } else {
+            // Try to marshal into an integer
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toLong(n);
+        }
+    }
+
+    public String getNString(int columnIndex) throws SQLException {
+        return this.getNString(this.findColumnLabel(columnIndex));
+    }
+
+    public String getNString(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return null;
+        } else {
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toString(n);
+        }
+    }
+
+    public Object getObject(int columnIndex) throws SQLException {
+        return this.getObject(this.findColumnLabel(columnIndex));
+    }
+
+    public Object getObject(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return null;
+        } else {
+            this.setNull(false);
+            return n;
+        }
+    }
+
+    public short getShort(int columnIndex) throws SQLException {
+        return this.getShort(this.findColumnLabel(columnIndex));
+    }
+
+    public short getShort(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return 0;
+        } else {
+            // Try to marshal into an integer
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toShort(n);
+        }
+    }
+
+    public String getString(int columnIndex) throws SQLException {
+        return this.getString(this.findColumnLabel(columnIndex));
+    }
+
+    public String getString(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return null;
+        } else {
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toString(n);
+        }
+    }
+
+    public Time getTime(int columnIndex) throws SQLException {
+        return this.getTime(this.findColumnLabel(columnIndex));
+    }
+
+    public Time getTime(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return null;
+        } else {
+            // Try to marshal into a time
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toTime(n);
+        }
+    }
+
+    public Timestamp getTimestamp(int columnIndex) throws SQLException {
+        return this.getTimestamp(this.findColumnLabel(columnIndex));
+    }
+
+    public Timestamp getTimestamp(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return null;
+        } else {
+            // Try to marshal into a timestamp
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toTimestamp(n);
+        }
+    }
+
+    public URL getURL(int columnIndex) throws SQLException {
+        return this.getURL(this.findColumnLabel(columnIndex));
+    }
+
+    public URL getURL(String columnLabel) throws SQLException {
+        Node n = this.getNode(columnLabel);
+        if (n == null) {
+            this.setNull(true);
+            return null;
+        } else {
+            this.setNull(false);
+            return JenaJdbcNodeUtils.toURL(n);
+        }
+    }
+
+    // Get Methods for things we don't support
+
+    public Array getArray(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Array getArray(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public InputStream getAsciiStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public InputStream getAsciiStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+    
+    @Deprecated
+    public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    @Deprecated
+    public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public InputStream getBinaryStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public InputStream getBinaryStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Blob getBlob(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Blob getBlob(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public byte[] getBytes(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public byte[] getBytes(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Reader getCharacterStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Reader getCharacterStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Clob getClob(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Clob getClob(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public String getCursorName() throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+    
+    public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Reader getNCharacterStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Reader getNCharacterStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public NClob getNClob(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public NClob getNClob(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+    
+    public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Ref getRef(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Ref getRef(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public RowId getRowId(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public RowId getRowId(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public SQLXML getSQLXML(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public SQLXML getSQLXML(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Statement getStatement() throws SQLException {
+        return this.statement;
+    }
+    
+    public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+    
+    public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    @Deprecated
+    public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    @Deprecated
+    public InputStream getUnicodeStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public final SQLWarning getWarnings() throws SQLException {
+        return this.warnings;
+    }
+
+    /**
+     * Helper method that derived classes may use to set warnings
+     * 
+     * @param warning
+     *            Warning
+     */
+    protected void setWarning(SQLWarning warning) {
+        if (this.warnings == null) {
+            this.warnings = warning;
+        } else {
+            // Chain with existing warnings
+            warning.setNextWarning(this.warnings);
+            this.warnings = warning;
+        }
+    }
+
+    /**
+     * Helper method that derived classes may use to set warnings
+     * 
+     * @param warning
+     *            Warning
+     */
+    protected void setWarning(String warning) {
+        this.setWarning(new SQLWarning(warning));
+    }
+
+    /**
+     * Helper method that derived classes may use to set warnings
+     * 
+     * @param warning
+     *            Warning
+     * @param cause
+     *            Cause
+     */
+    protected void setWarning(String warning, Throwable cause) {
+        this.setWarning(new SQLWarning(warning, cause));
+    }
+
+    public void insertRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void moveToCurrentRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public void moveToInsertRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public boolean previous() throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are forward-only");
+    }
+
+    public void refreshRow() throws SQLException {
+        // No-op
+    }
+
+    public boolean rowDeleted() throws SQLException {
+        return false;
+    }
+
+    public boolean rowInserted() throws SQLException {
+        return false;
+    }
+
+    public boolean rowUpdated() throws SQLException {
+        return false;
+    }
+
+    public void updateArray(int columnIndex, Array x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateArray(String columnLabel, Array x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBlob(int columnIndex, Blob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBlob(String columnLabel, Blob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBoolean(String columnLabel, boolean x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateByte(int columnIndex, byte x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateByte(String columnLabel, byte x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateBytes(String columnLabel, byte[] x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateClob(int columnIndex, Clob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateClob(int columnIndex, Reader reader) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateClob(String columnLabel, Clob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateClob(String columnLabel, Reader reader) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateDate(int columnIndex, Date x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateDate(String columnLabel, Date x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateDouble(int columnIndex, double x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateDouble(String columnLabel, double x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateFloat(int columnIndex, float x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateFloat(String columnLabel, float x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateInt(int columnIndex, int x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateInt(String columnLabel, int x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateLong(int columnIndex, long x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateLong(String columnLabel, long x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNClob(int columnIndex, Reader reader) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNClob(String columnLabel, Reader reader) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNString(int columnIndex, String nString) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNString(String columnLabel, String nString) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNull(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateNull(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateObject(int columnIndex, Object x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateObject(String columnLabel, Object x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateRef(int columnIndex, Ref x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateRef(String columnLabel, Ref x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateRowId(int columnIndex, RowId x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateRowId(String columnLabel, RowId x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateShort(int columnIndex, short x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateShort(String columnLabel, short x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateString(int columnIndex, String x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateString(String columnLabel, String x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateTime(int columnIndex, Time x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateTime(String columnLabel, Time x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("Jena JDBC Result Sets are read-only");
+    }
+
+    public boolean wasNull() throws SQLException {
+        return this.wasNull;
+    }
+
+    /**
+     * Helper method for setting the wasNull() status of the last column read
+     * 
+     * @param wasNull
+     *            Whether the last column was null
+     */
+    protected void setNull(boolean wasNull) {
+        this.wasNull = wasNull;
+    }
+
+}

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/QueryExecutionResults.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/QueryExecutionResults.java?rev=1464215&r1=1464214&r2=1464215&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/QueryExecutionResults.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/QueryExecutionResults.java Wed Apr  3 22:01:26 2013
@@ -27,7 +27,7 @@ import com.hp.hpl.jena.query.QueryExecut
  * Abstract base class for result sets that are backed by a {@link QueryExecution} 
  *
  */
-public abstract class QueryExecutionResults extends JenaJdbcResultSet {
+public abstract class QueryExecutionResults extends JenaResultSet {
 
     private QueryExecution qe;
     private boolean commit = false;

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/AskResultsMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/AskResultsMetadata.java?rev=1464215&r1=1464214&r2=1464215&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/AskResultsMetadata.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/AskResultsMetadata.java Wed Apr  3 22:01:26 2013
@@ -27,7 +27,7 @@ import org.apache.jena.jdbc.results.AskR
  * Meta data for {@link AskResults}
  *
  */
-public class AskResultsMetadata extends JenaJdbcResultsMetadata {
+public class AskResultsMetadata extends JenaResultsMetadata {
     
     /**
      * Constant for the ASK results column label

Added: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/JenaResultsMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/JenaResultsMetadata.java?rev=1464215&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/JenaResultsMetadata.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/JenaResultsMetadata.java Wed Apr  3 22:01:26 2013
@@ -0,0 +1,172 @@
+/**
+ * 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.results.metadata;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.Types;
+
+import com.hp.hpl.jena.graph.Node;
+
+/**
+ * Abstract implementation of result set metadata for Jena JDBC result sets
+ * 
+ */
+public abstract class JenaResultsMetadata implements ResultSetMetaData {
+
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public String getCatalogName(int column) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public String getColumnClassName(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // All columns are typed as String in order that generic JDBC tools
+        // can actually understand our results
+        return String.class.getCanonicalName();
+    }
+
+    public abstract int getColumnCount() throws SQLException;
+
+    /**
+     * Gets a columns display size
+     * <p>
+     * Since RDF imposes no maximum on the size of a term this may be
+     * arbitrarily large hence {@link Integer#MAX_VALUE} is returned, users
+     * should not rely on this method to give them accurate information for UI
+     * usage.
+     * </p>
+     */
+    public int getColumnDisplaySize(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // No max size for columns so return maximum possible
+        return Integer.MAX_VALUE;
+    }
+
+    public abstract String getColumnLabel(int column) throws SQLException;
+
+    public String getColumnName(int column) throws SQLException {
+        return this.getColumnLabel(column);
+    }
+
+    public int getColumnType(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // All columns are typed as Java Object from a JDBC SQL type perspective
+        return Types.NVARCHAR;
+    }
+
+    public String getColumnTypeName(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // The underlying type is actually ARQ Node
+        return Node.class.getCanonicalName();
+    }
+
+    public int getPrecision(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // Precision is not a supported notion in RDF/SPARQL
+        // Precision can vary depending on data type
+        return 0;
+    }
+
+    public int getScale(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // Scale is not a supported notion in RDF/SPARQL
+        // Scale can vary depending on data type
+        return 0;
+    }
+
+    public String getSchemaName(int column) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public String getTableName(int column) throws SQLException {
+        throw new SQLFeatureNotSupportedException();
+    }
+
+    public boolean isAutoIncrement(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // SPARQL engines don't have a notion of auto-increment
+        return false;
+    }
+
+    public boolean isCaseSensitive(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // Most types in RDF/SPARQL are subject to case sensitivity especially
+        // when talking strict RDF equality semantics
+        return true;
+    }
+
+    public boolean isCurrency(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // No built in currency type in RDF
+        return false;
+    }
+
+    public boolean isDefinitelyWritable(int column) throws SQLException {
+        return this.isWritable(column);
+    }
+
+    public abstract int isNullable(int column) throws SQLException;
+
+    public boolean isReadOnly(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // All Jena JDBC results are read-only currently
+        return true;
+    }
+
+    public boolean isSearchable(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // All columns are searchable in RDF/SPARQL
+        return true;
+    }
+
+    public boolean isSigned(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // Most numeric types allow for signs in RDF/SPARQL
+        return true;
+    }
+
+    public boolean isWritable(int column) throws SQLException {
+        // Call getColumnName to validate the column index
+        this.getColumnName(column);
+        // All Jena JDBC results are read-only currently
+        return false;
+    }
+
+}

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java?rev=1464215&r1=1464214&r2=1464215&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java Wed Apr  3 22:01:26 2013
@@ -29,7 +29,7 @@ import com.hp.hpl.jena.query.ResultSet;
  * Result Set Metadata for {@link SelectResults} instances 
  *
  */
-public class SelectResultsMetadata extends JenaJdbcResultsMetadata {
+public class SelectResultsMetadata extends JenaResultsMetadata {
 
     @SuppressWarnings("unused")
     private ResultSet innerResults;

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java?rev=1464215&r1=1464214&r2=1464215&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java Wed Apr  3 22:01:26 2013
@@ -26,7 +26,7 @@ import org.apache.jena.jdbc.results.Trip
  * Result set metadata for {@link TripleIteratorResults} instances
  *
  */
-public class TripleResultsMetadata extends JenaJdbcResultsMetadata {
+public class TripleResultsMetadata extends JenaResultsMetadata {
 
     /**
      * Constant for the subject column label

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java?rev=1464215&r1=1464214&r2=1464215&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java Wed Apr  3 22:01:26 2013
@@ -30,7 +30,7 @@ import java.util.List;
 import java.util.Queue;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.jena.jdbc.connections.JenaJdbcConnection;
+import org.apache.jena.jdbc.connections.JenaConnection;
 import org.apache.jena.jdbc.results.AskResults;
 import org.apache.jena.jdbc.results.SelectResults;
 import org.apache.jena.jdbc.results.TripleIteratorResults;
@@ -53,8 +53,8 @@ public abstract class JenaJdbcStatement 
     protected static final int DEFAULT_HOLDABILITY = ResultSet.CLOSE_CURSORS_AT_COMMIT;
     protected static final int DEFAULT_FETCH_DIRECTION = ResultSet.FETCH_FORWARD;
     protected static final int DEFAULT_FETCH_SIZE = 0;
-    protected static final boolean DEFAULT_AUTO_COMMIT = JenaJdbcConnection.DEFAULT_AUTO_COMMIT;
-    protected static final int DEFAULT_TRANSACTION_LEVEL = JenaJdbcConnection.DEFAULT_ISOLATION_LEVEL;
+    protected static final boolean DEFAULT_AUTO_COMMIT = JenaConnection.DEFAULT_AUTO_COMMIT;
+    protected static final int DEFAULT_TRANSACTION_LEVEL = JenaConnection.DEFAULT_ISOLATION_LEVEL;
     protected static final int NO_LIMIT = 0;
 
     private List<String> commands = new ArrayList<String>();
@@ -235,12 +235,7 @@ public abstract class JenaJdbcStatement 
             } else if (q.isAskType()) {
                 boolean askRes = qe.execAsk();
                 qe.close();
-                this.currResults = new AskResults(this, askRes);
-
-                // Can commit immediately after an ASK returns
-                if (needsCommit) {
-                    this.commitTransaction();
-                }
+                this.currResults = new AskResults(this, askRes, needsCommit);
                 return true;
             } else if (q.isDescribeType()) {
                 this.currResults = new TripleIteratorResults(this, qe, qe.execDescribeTriples(), needsCommit);

Added: 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=1464215&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/AbstractJenaDriverTests.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/AbstractJenaDriverTests.java Wed Apr  3 22:01:26 2013
@@ -0,0 +1,139 @@
+/**
+ * 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;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+
+import com.hp.hpl.jena.query.ARQ;
+
+/**
+ * Abstract tests for {@link JenaDriver} implementations
+ * 
+ */
+public abstract class AbstractJenaDriverTests {
+
+    static {
+        // Init Log4j
+        BasicConfigurator.resetConfiguration();
+        BasicConfigurator.configure();
+        Logger.getRootLogger().setLevel(Level.INFO);
+
+        // Init ARQ
+        ARQ.init();
+    }
+
+    /**
+     * Method which derived classes must implement to return an instance of
+     * their driver implementation.
+     */
+    protected abstract JenaDriver getDriver();
+
+    /**
+     * Method which derived classes must implement to provide a connection URL
+     * for an empty database.
+     * <p>
+     * {@code null} may be returned if this is not supported by the driver
+     * implementation. If this is the case then relevant tests will be skipped.
+     * </p>
+     * 
+     * @return Connection URL or null
+     */
+    protected abstract String getConnectionUrl();
+
+    /**
+     * Method which derives classes must implement to provide a connection URL
+     * which is known to result in a creation error in the form of a
+     * {@link SQLException} when the
+     * {@link JenaDriver#connect(String, java.util.Properties)} is called
+     * with it.
+     * <p>
+     * {@code null} may be returned if there are no invalid connection URLs for
+     * the driver (this is considered highly unlikely)
+     * </p>
+     * 
+     * @return Bad Connection URL or null
+     */
+    protected abstract String getBadConnectionUrl();
+
+    /**
+     * Test that an implementation will accept its own URLs
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_accepts_01() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        JenaDriver driver = this.getDriver();
+
+        Assert.assertTrue(driver.acceptsURL(url));
+    }
+
+    /**
+     * Tests that an implementation will not accept an arbitrary URL
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_accepts_02() throws SQLException {
+        String url = "jdbc:unknown:http://example.org";
+        JenaDriver driver = this.getDriver();
+
+        Assert.assertFalse(driver.acceptsURL(url));
+    }
+
+    /**
+     * Tests using a driver to create a connection with its own URLs
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void driver_connect_01() throws SQLException {
+        String url = this.getConnectionUrl();
+        Assume.assumeNotNull(url);
+        JenaDriver driver = this.getDriver();
+
+        Connection conn = driver.connect(url, null);
+        Assert.assertFalse(conn.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Tests using a driver to create a connection with its own URLs which are known to be bad
+     * 
+     * @throws SQLException
+     */
+    @Test(expected=SQLException.class)
+    public void driver_connect_02() throws SQLException {
+        String url = this.getBadConnectionUrl();
+        Assume.assumeNotNull(url);
+        JenaDriver driver = this.getDriver();
+
+        driver.connect(url, null);
+    }
+}

Added: jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java?rev=1464215&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java Wed Apr  3 22:01:26 2013
@@ -0,0 +1,572 @@
+/**
+ * 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.connections;
+
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+
+import org.apache.jena.jdbc.connections.JenaConnection;
+import org.apache.jena.jdbc.results.metadata.TripleResultsMetadata;
+import org.apache.jena.jdbc.utils.TestUtils;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.NodeFactory;
+import com.hp.hpl.jena.query.ARQ;
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.query.DatasetFactory;
+import com.hp.hpl.jena.sparql.core.Quad;
+
+/**
+ * Abstract tests for {@link JenaConnection} implementations
+ * 
+ */
+public abstract class AbstractJenaConnectionTests {
+
+    static {
+        // Init Log4j
+        BasicConfigurator.resetConfiguration();
+        BasicConfigurator.configure();
+        Logger.getRootLogger().setLevel(Level.INFO);
+
+        // Init ARQ
+        ARQ.init();
+    }
+
+    /**
+     * Method which derived test classes must implement to provide a connection
+     * to an empty database for testing
+     * 
+     * @return Connection
+     * @throws SQLException
+     */
+    protected abstract JenaConnection getConnection() throws SQLException;
+
+    /**
+     * Method which derived test classes must implement to provide a connection
+     * to a database constructed from the given dataset for testing
+     * 
+     * @return Connection
+     * @throws SQLException
+     */
+    protected abstract JenaConnection getConnection(Dataset ds) throws SQLException;
+
+    /**
+     * Create and close a connection to an empty database
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_create_close_01() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Assert.assertFalse(conn.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    /**
+     * Create and close a connection to an explicitly provided empty database
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_create_close_02() throws SQLException {
+        JenaConnection conn = this.getConnection(DatasetFactory.createMem());
+        Assert.assertFalse(conn.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    /**
+     * Retrieve and close a statement
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_get_statement_01() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        Assert.assertNotNull(stmt);
+        Assert.assertFalse(stmt.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Trying to retrieve a statement from a closed connection is an error
+     * 
+     * @throws SQLException
+     */
+    @Test(expected=SQLException.class)
+    public void connection_get_statement_02() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+        
+        // Trying to create a statement after the connection is closed is an error
+        conn.createStatement();
+    }
+    
+    /**
+     * Trying to use a statement from a closed connection is an error
+     * @throws SQLException
+     */
+    @Test(expected=SQLException.class)
+    public void connection_get_statement_03() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        Assert.assertNotNull(stmt);
+        Assert.assertFalse(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+        
+        // Trying to use a statement after the connection is closed is an error
+        stmt.execute("SELECT * { ?s ?p ?o }");
+    }
+
+    /**
+     * Runs a SELECT query on an empty database and checks it returns empty
+     * results
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_select_01() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        ResultSet rset = stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+        Assert.assertNotNull(rset);
+
+        // Check result set metadata
+        checkSelectMetadata(rset, 3);
+
+        // Check result set
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(stmt.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    /**
+     * Runs a SELECT query on a non-empty database and checks it returns
+     * non-empty results
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_select_02() throws SQLException {
+        // Prepare a dataset
+        Dataset ds = DatasetFactory.createMem();
+        ds.asDatasetGraph().add(
+                new Quad(NodeFactory.createURI("http://example/graph"), NodeFactory.createURI("http://example/subject"),
+                        NodeFactory.createURI("http://example/predicate"), NodeFactory.createURI("http://example/object")));
+
+        // Work with the connection
+        JenaConnection conn = this.getConnection(ds);
+        Statement stmt = conn.createStatement();
+        ResultSet rset = stmt.executeQuery("SELECT * WHERE { GRAPH ?g { ?s ?p ?o } }");
+        Assert.assertNotNull(rset);
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+
+        // Check result set metadata
+        checkSelectMetadata(rset, 4);
+
+        // Should have a row
+        Assert.assertTrue(rset.next());
+        Assert.assertTrue(rset.isFirst());
+        Assert.assertEquals(1, rset.getRow());
+
+        // Should be no further rows
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(rset.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    /**
+     * Runs a SELECT query on a non-empty database and checks it returns
+     * non-empty results
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_select_03() throws SQLException {
+        // Prepare a dataset
+        Dataset ds = DatasetFactory.createMem();
+        ds.asDatasetGraph().add(
+                new Quad(NodeFactory.createURI("http://example/graph"), NodeFactory.createURI("http://example/subject"),
+                        NodeFactory.createURI("http://example/predicate"), NodeFactory.createURI("http://example/object")));
+
+        // Work with the connection
+        JenaConnection conn = this.getConnection(ds);
+        Statement stmt = conn.createStatement();
+        ResultSet rset = stmt.executeQuery("SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }");
+        Assert.assertNotNull(rset);
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+
+        // Check result set metadata
+        checkSelectMetadata(rset, 1);
+
+        // Should have a row
+        Assert.assertTrue(rset.next());
+        Assert.assertTrue(rset.isFirst());
+        Assert.assertEquals(1, rset.getRow());
+
+        // Should be no further rows
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(rset.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Runs a SELECT query on a non-empty database with max rows set and checks that
+     * the appropriate number of rows are returned
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_select_max_rows_01() throws SQLException {
+        // Prepare a dataset
+        Dataset ds = TestUtils.generateDataset(3, 10, false);
+
+        // Work with the connection
+        JenaConnection conn = this.getConnection(ds);
+        Statement stmt = conn.createStatement();
+        stmt.setMaxRows(10);
+        ResultSet rset = stmt.executeQuery("SELECT * WHERE { GRAPH ?g { ?s ?p ?o } }");
+        Assert.assertNotNull(rset);
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+
+        // Check result set metadata
+        checkSelectMetadata(rset, 4);
+
+        // Check expected number of rows
+        int count = 0;
+        while (rset.next()) {
+            count++;
+        }
+        Assert.assertEquals(10, count);
+
+        // Should be no further rows
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(rset.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+    
+    /**
+     * Runs a SELECT query on a non-empty database with max rows set and checks that
+     * the appropriate number of rows are returned
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_select_max_rows_02() throws SQLException {
+        // Prepare a dataset
+        Dataset ds = TestUtils.generateDataset(3, 10, false);
+
+        // Work with the connection
+        JenaConnection conn = this.getConnection(ds);
+        Statement stmt = conn.createStatement();
+        
+        // Set max rows to 10, note that if the query specifies a lower limit then that is respected
+        stmt.setMaxRows(10);
+        ResultSet rset = stmt.executeQuery("SELECT * WHERE { GRAPH ?g { ?s ?p ?o } } LIMIT 1");
+        Assert.assertNotNull(rset);
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+
+        // Check result set metadata
+        checkSelectMetadata(rset, 4);
+
+        // Check expected number of rows
+        int count = 0;
+        while (rset.next()) {
+            count++;
+        }
+        Assert.assertEquals(1, count);
+
+        // Should be no further rows
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(rset.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    protected void checkSelectMetadata(ResultSet results, int numColumns) throws SQLException {
+        ResultSetMetaData metadata = results.getMetaData();
+        Assert.assertEquals(numColumns, metadata.getColumnCount());
+        for (int i = 1; i <= numColumns; i++) {
+            Assert.assertEquals(String.class.getCanonicalName(), metadata.getColumnClassName(i));
+            Assert.assertEquals(Node.class.getCanonicalName(), metadata.getColumnTypeName(i));
+            Assert.assertEquals(Types.NVARCHAR, metadata.getColumnType(i));
+        }
+    }
+
+    /**
+     * Runs an ASK query on an empty database and checks it returns true
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_ask_01() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        ResultSet rset = stmt.executeQuery("ASK WHERE { }");
+        Assert.assertNotNull(rset);
+
+        // Check result set metadata
+        checkAskMetadata(rset);
+
+        // Check result set
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+        Assert.assertTrue(rset.next());
+        Assert.assertTrue(rset.getBoolean(1));
+
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    protected void checkAskMetadata(ResultSet results) throws SQLException {
+        ResultSetMetaData metadata = results.getMetaData();
+        Assert.assertEquals(1, metadata.getColumnCount());
+        Assert.assertEquals(Boolean.class.getCanonicalName(), metadata.getColumnClassName(1));
+        Assert.assertEquals(Boolean.class.getCanonicalName(), metadata.getColumnTypeName(1));
+        Assert.assertEquals(Types.BOOLEAN, metadata.getColumnType(1));
+    }
+
+    /**
+     * Runs a CONSTRUCT query on an empty database and checks it returns empty
+     * results
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_construct_01() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        ResultSet rset = stmt.executeQuery("CONSTRUCT WHERE { ?s ?p ?o }");
+        Assert.assertNotNull(rset);
+
+        // Check result set metadata
+        checkConstructDescribeMetadata(rset);
+
+        // Check result set
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(rset.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    /**
+     * Runs a CONSTRUCT query on a non-empty database and checks it returns
+     * non-empty results
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_construct_02() throws SQLException {
+        // Prepare a dataset
+        Dataset ds = DatasetFactory.createMem();
+        ds.asDatasetGraph().add(
+                new Quad(NodeFactory.createURI("http://example/graph"), NodeFactory.createURI("http://example/subject"),
+                        NodeFactory.createURI("http://example/predicate"), NodeFactory.createURI("http://example/object")));
+
+        // Work with the connection
+        JenaConnection conn = this.getConnection(ds);
+        Statement stmt = conn.createStatement();
+        ResultSet rset = stmt.executeQuery("CONSTRUCT { ?s ?p ?o } WHERE { GRAPH ?g { ?s ?p ?o } }");
+        Assert.assertNotNull(rset);
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+
+        // Should have a row
+        Assert.assertTrue(rset.next());
+        Assert.assertTrue(rset.isFirst());
+        Assert.assertEquals(1, rset.getRow());
+
+        // Should be no further rows
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(rset.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    /**
+     * Runs a CONSTRUCT query on an empty database and checks it returns empty
+     * results
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_describe_01() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        ResultSet rset = stmt.executeQuery("DESCRIBE <http://subject>");
+        Assert.assertNotNull(rset);
+
+        // Check result set metadata
+        checkConstructDescribeMetadata(rset);
+
+        // Check result set
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(rset.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    /**
+     * Runs a CONSTRUCT query on a non-empty database and checks it returns
+     * non-empty results
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_query_describe_02() throws SQLException {
+        // Prepare a dataset
+        Dataset ds = DatasetFactory.createMem();
+        ds.asDatasetGraph().add(
+                new Quad(NodeFactory.createURI("http://example/graph"), NodeFactory.createURI("http://example/subject"),
+                        NodeFactory.createURI("http://example/predicate"), NodeFactory.createURI("http://example/object")));
+
+        // Work with the connection
+        JenaConnection conn = this.getConnection(ds);
+        Statement stmt = conn.createStatement();
+        ResultSet rset = stmt.executeQuery("DESCRIBE ?s WHERE { GRAPH ?g { ?s ?p ?o } }");
+        Assert.assertNotNull(rset);
+        Assert.assertFalse(rset.isClosed());
+        Assert.assertTrue(rset.isBeforeFirst());
+
+        // Should have a row
+        Assert.assertTrue(rset.next());
+        Assert.assertTrue(rset.isFirst());
+        Assert.assertEquals(1, rset.getRow());
+
+        // Should be no further rows
+        Assert.assertFalse(rset.next());
+        Assert.assertTrue(rset.isAfterLast());
+        Assert.assertFalse(rset.isClosed());
+
+        // Close things
+        rset.close();
+        Assert.assertTrue(rset.isClosed());
+        stmt.close();
+        Assert.assertTrue(stmt.isClosed());
+        conn.close();
+        Assert.assertTrue(conn.isClosed());
+    }
+
+    protected void checkConstructDescribeMetadata(ResultSet results) throws SQLException {
+        // Check result set metadata
+        ResultSetMetaData metadata = results.getMetaData();
+        Assert.assertEquals(3, metadata.getColumnCount());
+        for (int i = 1; i <= TripleResultsMetadata.NUM_COLUMNS; i++) {
+            Assert.assertEquals(String.class.getCanonicalName(), metadata.getColumnClassName(i));
+            Assert.assertEquals(Node.class.getCanonicalName(), metadata.getColumnTypeName(i));
+            Assert.assertEquals(Types.NVARCHAR, metadata.getColumnType(i));
+        }
+    }
+    
+    public void connection_transactions_01() throws SQLException {
+        
+    }
+}

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java?rev=1464215&r1=1464214&r2=1464215&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java Wed Apr  3 22:01:26 2013
@@ -148,6 +148,7 @@ public abstract class AbstractResultSetT
     @Test
     public void test_results_ask_true() throws SQLException {
         ResultSet rset = this.createResults(AbstractResultSetTests.empty, "ASK { }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
 
@@ -174,6 +175,7 @@ public abstract class AbstractResultSetT
     @Test
     public void test_results_ask_false() throws SQLException {
         ResultSet rset = this.createResults(AbstractResultSetTests.empty, "ASK { FILTER(false) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
 
@@ -200,6 +202,7 @@ public abstract class AbstractResultSetT
     @Test
     public void test_results_select_strings_01() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT (STR(?o) AS ?str) { ?s ?p ?o . FILTER(!ISBLANK(?o)) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -223,6 +226,7 @@ public abstract class AbstractResultSetT
     @Test
     public void test_results_select_strings_02() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT (STR(?o) AS ?str) { ?s ?p ?o . FILTER(!ISBLANK(?o)) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -247,6 +251,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_strings_01() throws SQLException {
         ResultSet rset = this.createResults(ds,
                 "CONSTRUCT { ?s ?p ?str } WHERE { ?s ?p ?o . FILTER(!ISBLANK(?o)) . BIND(STR(?o) AS ?str) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -271,6 +276,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_strings_02() throws SQLException {
         ResultSet rset = this.createResults(ds,
                 "CONSTRUCT { ?s ?p ?str } WHERE { ?s ?p ?o . FILTER(!ISBLANK(?o)) . BIND(STR(?o) AS ?str) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -294,6 +300,7 @@ public abstract class AbstractResultSetT
     @Test
     public void test_results_select_numerics() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(ISNUMERIC(?o)) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -321,6 +328,7 @@ public abstract class AbstractResultSetT
     @Test
     public void test_results_construct_numerics() throws SQLException {
         ResultSet rset = this.createResults(ds, "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(ISNUMERIC(?o)) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -349,6 +357,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_integers() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + this.getIntegerTypeUri()
                 + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -374,6 +383,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_integers() throws SQLException {
         ResultSet rset = this.createResults(ds,
                 "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + this.getIntegerTypeUri() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -399,6 +409,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_bytes() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + this.getByteTypeUri()
                 + "> && ?o <= 255) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -425,6 +436,7 @@ public abstract class AbstractResultSetT
         ResultSet rset = this
                 .createResults(ds, "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + this.getByteTypeUri()
                         + "> && ?o <= 255) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -450,6 +462,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_floats() throws SQLException {
         ResultSet rset = this
                 .createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + XSD.xfloat.toString() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -475,6 +488,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_floats() throws SQLException {
         ResultSet rset = this.createResults(ds,
                 "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + XSD.xfloat.toString() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -500,6 +514,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_doubles() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + XSD.xdouble.toString()
                 + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -525,6 +540,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_doubles() throws SQLException {
         ResultSet rset = this.createResults(ds,
                 "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + XSD.xdouble.toString() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -550,6 +566,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_longs() throws SQLException {
         ResultSet rset = this
                 .createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + this.getLongTypeUri() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -575,6 +592,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_longs() throws SQLException {
         ResultSet rset = this.createResults(ds,
                 "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + this.getLongTypeUri() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -600,6 +618,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_shorts() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + this.getShortTypeUri()
                 + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -625,6 +644,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_shorts() throws SQLException {
         ResultSet rset = this.createResults(ds,
                 "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + this.getShortTypeUri() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -650,6 +670,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_dates_01() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + XSD.dateTime.toString()
                 + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -675,6 +696,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_dates_02() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + XSD.dateTime.toString()
                 + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -700,6 +722,7 @@ public abstract class AbstractResultSetT
     public void test_results_select_dates_03() throws SQLException {
         ResultSet rset = this.createResults(ds, "SELECT ?o { ?s ?p ?o . FILTER(DATATYPE(?o) = <" + XSD.dateTime.toString()
                 + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -725,6 +748,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_dates_01() throws SQLException {
         ResultSet rset = this.createResults(ds, "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <"
                 + XSD.dateTime.toString() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -750,6 +774,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_dates_02() throws SQLException {
         ResultSet rset = this.createResults(ds, "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <"
                 + XSD.dateTime.toString() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());
@@ -775,6 +800,7 @@ public abstract class AbstractResultSetT
     public void test_results_construct_dates_03() throws SQLException {
         ResultSet rset = this.createResults(ds, "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER(DATATYPE(?o) = <"
                 + XSD.dateTime.toString() + ">) }");
+        Assert.assertNotNull(rset);
         Assert.assertFalse(rset.isClosed());
         Assert.assertTrue(rset.isBeforeFirst());
         Assert.assertFalse(rset.isLast());