You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2008/12/09 19:12:47 UTC

svn commit: r724803 - in /jackrabbit/sandbox/jackrabbit-jdbc2jcr/src: main/java/org/apache/jackrabbit/jdbc/ test/java/org/apache/jackrabbit/jdbc/

Author: jukka
Date: Tue Dec  9 10:12:46 2008
New Revision: 724803

URL: http://svn.apache.org/viewvc?rev=724803&view=rev
Log:
jdbc2jcr: Some simple JDBC to JCR mapping code. Work in progress... 

Added:
    jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRConnection.java   (with props)
    jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRDriver.java   (with props)
    jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRResultSet.java   (with props)
Modified:
    jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/TpsReport.java
    jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/test/java/org/apache/jackrabbit/jdbc/Fixture.java

Added: jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRConnection.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRConnection.java?rev=724803&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRConnection.java (added)
+++ jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRConnection.java Tue Dec  9 10:12:46 2008
@@ -0,0 +1,261 @@
+package org.apache.jackrabbit.jdbc;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.io.FileUtils;
+
+class JCRConnection implements Connection {
+
+    private final Connection connection;
+
+    private final File tmp;
+
+    public JCRConnection(Connection connection, File tmp) {
+        this.connection = connection;
+        this.tmp = tmp;
+
+        
+    }
+
+    public void close() throws SQLException {
+        connection.close();
+        try {
+            FileUtils.deleteDirectory(tmp);
+        } catch (IOException e) {
+            throw new SQLException("Error removing temporary directory", e);
+        }
+    }
+
+    //----------------------------------------------------< Delegate methods >
+
+    public void clearWarnings() throws SQLException {
+        connection.clearWarnings();
+    }
+
+    public void commit() throws SQLException {
+        connection.commit();
+    }
+
+    public Array createArrayOf(String typeName, Object[] elements)
+            throws SQLException {
+        return connection.createArrayOf(typeName, elements);
+    }
+
+    public Blob createBlob() throws SQLException {
+        return connection.createBlob();
+    }
+
+    public Clob createClob() throws SQLException {
+        return connection.createClob();
+    }
+
+    public NClob createNClob() throws SQLException {
+        return connection.createNClob();
+    }
+
+    public SQLXML createSQLXML() throws SQLException {
+        return connection.createSQLXML();
+    }
+
+    public Statement createStatement() throws SQLException {
+        return connection.createStatement();
+    }
+
+    public Statement createStatement(int resultSetType,
+            int resultSetConcurrency, int resultSetHoldability)
+            throws SQLException {
+        return connection.createStatement(resultSetType, resultSetConcurrency,
+                resultSetHoldability);
+    }
+
+    public Statement createStatement(int resultSetType, int resultSetConcurrency)
+            throws SQLException {
+        return connection.createStatement(resultSetType, resultSetConcurrency);
+    }
+
+    public Struct createStruct(String typeName, Object[] attributes)
+            throws SQLException {
+        return connection.createStruct(typeName, attributes);
+    }
+
+    public boolean getAutoCommit() throws SQLException {
+        return connection.getAutoCommit();
+    }
+
+    public String getCatalog() throws SQLException {
+        return connection.getCatalog();
+    }
+
+    public Properties getClientInfo() throws SQLException {
+        return connection.getClientInfo();
+    }
+
+    public String getClientInfo(String name) throws SQLException {
+        return connection.getClientInfo(name);
+    }
+
+    public int getHoldability() throws SQLException {
+        return connection.getHoldability();
+    }
+
+    public DatabaseMetaData getMetaData() throws SQLException {
+        return connection.getMetaData();
+    }
+
+    public int getTransactionIsolation() throws SQLException {
+        return connection.getTransactionIsolation();
+    }
+
+    public Map<String, Class<?>> getTypeMap() throws SQLException {
+        return connection.getTypeMap();
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        return connection.getWarnings();
+    }
+
+    public boolean isClosed() throws SQLException {
+        return connection.isClosed();
+    }
+
+    public boolean isReadOnly() throws SQLException {
+        return connection.isReadOnly();
+    }
+
+    public boolean isValid(int timeout) throws SQLException {
+        return connection.isValid(timeout);
+    }
+
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        return connection.isWrapperFor(iface);
+    }
+
+    public String nativeSQL(String sql) throws SQLException {
+        return connection.nativeSQL(sql);
+    }
+
+    public CallableStatement prepareCall(String sql, int resultSetType,
+            int resultSetConcurrency, int resultSetHoldability)
+            throws SQLException {
+        return connection.prepareCall(sql, resultSetType, resultSetConcurrency,
+                resultSetHoldability);
+    }
+
+    public CallableStatement prepareCall(String sql, int resultSetType,
+            int resultSetConcurrency) throws SQLException {
+        return connection.prepareCall(sql, resultSetType, resultSetConcurrency);
+    }
+
+    public CallableStatement prepareCall(String sql) throws SQLException {
+        return connection.prepareCall(sql);
+    }
+
+    public PreparedStatement prepareStatement(String sql, int resultSetType,
+            int resultSetConcurrency, int resultSetHoldability)
+            throws SQLException {
+        return connection.prepareStatement(sql, resultSetType,
+                resultSetConcurrency, resultSetHoldability);
+    }
+
+    public PreparedStatement prepareStatement(String sql, int resultSetType,
+            int resultSetConcurrency) throws SQLException {
+        return connection.prepareStatement(sql, resultSetType,
+                resultSetConcurrency);
+    }
+
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
+            throws SQLException {
+        return connection.prepareStatement(sql, autoGeneratedKeys);
+    }
+
+    public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
+            throws SQLException {
+        return connection.prepareStatement(sql, columnIndexes);
+    }
+
+    public PreparedStatement prepareStatement(String sql, String[] columnNames)
+            throws SQLException {
+        return connection.prepareStatement(sql, columnNames);
+    }
+
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        return connection.prepareStatement(sql);
+    }
+
+    public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+        connection.releaseSavepoint(savepoint);
+    }
+
+    public void rollback() throws SQLException {
+        connection.rollback();
+    }
+
+    public void rollback(Savepoint savepoint) throws SQLException {
+        connection.rollback(savepoint);
+    }
+
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        connection.setAutoCommit(autoCommit);
+    }
+
+    public void setCatalog(String catalog) throws SQLException {
+        connection.setCatalog(catalog);
+    }
+
+    public void setClientInfo(Properties properties)
+            throws SQLClientInfoException {
+        connection.setClientInfo(properties);
+    }
+
+    public void setClientInfo(String name, String value)
+            throws SQLClientInfoException {
+        connection.setClientInfo(name, value);
+    }
+
+    public void setHoldability(int holdability) throws SQLException {
+        connection.setHoldability(holdability);
+    }
+
+    public void setReadOnly(boolean readOnly) throws SQLException {
+        connection.setReadOnly(readOnly);
+    }
+
+    public Savepoint setSavepoint() throws SQLException {
+        return connection.setSavepoint();
+    }
+
+    public Savepoint setSavepoint(String name) throws SQLException {
+        return connection.setSavepoint(name);
+    }
+
+    public void setTransactionIsolation(int level) throws SQLException {
+        connection.setTransactionIsolation(level);
+    }
+
+    public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+        connection.setTypeMap(map);
+    }
+
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        return connection.unwrap(iface);
+    }
+
+}

Propchange: jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRDriver.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRDriver.java?rev=724803&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRDriver.java (added)
+++ jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRDriver.java Tue Dec  9 10:12:46 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.jackrabbit.jdbc;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.apache.derby.jdbc.EmbeddedDriver;
+
+public class JCRDriver extends EmbeddedDriver {
+
+    @Override
+    public Connection connect(String url, Properties info) throws SQLException {
+        try {
+            File tmp = File.createTempFile("jcr", "jdbc");
+            tmp.delete();
+            tmp.mkdir();
+
+            Properties properties = new Properties(info);
+            properties.setProperty("create", "true");
+            return new JCRConnection(
+                    super.connect("jdbc:derby:" + tmp.getPath(), properties),
+                    tmp);
+        } catch (IOException e) {
+            throw new SQLException("Unable to create temporary directory", e);
+        }
+    }
+
+    @Override
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
+        // TODO: Should we delegate this to Derby?
+        return new DriverPropertyInfo[0];
+    }
+
+    @Override
+    public int getMajorVersion() {
+        return 0;
+    }
+
+    @Override
+    public int getMinorVersion() {
+        return 1;
+    }
+
+    @Override
+    public boolean acceptsURL(String url) {
+        return url != null && url.startsWith("jdbc:jcr:");
+    }
+
+    @Override
+    public boolean jdbcCompliant() {
+        return false;
+    }
+
+}

Propchange: jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRDriver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRResultSet.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRResultSet.java?rev=724803&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRResultSet.java (added)
+++ jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRResultSet.java Tue Dec  9 10:12:46 2008
@@ -0,0 +1,1086 @@
+package org.apache.jackrabbit.jdbc;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.RowIterator;
+
+public class JCRResultSet implements ResultSet {
+
+    private final Session session;
+
+    private final RowIterator rows;
+
+    private final String[] names;
+
+    private Value[] values = null;
+
+    public static ResultSet query(String statement, String language)
+            throws RepositoryException {
+        return new JCRResultSet(statement, language);
+    }
+
+    private JCRResultSet(String statement, String language)
+            throws RepositoryException {
+        session = null;
+
+        QueryManager manager = session.getWorkspace().getQueryManager();
+        Query query = manager.createQuery(statement, language);
+        QueryResult result = query.execute();
+        rows = result.getRows();
+        names = result.getColumnNames();
+    }
+
+    public void close() throws SQLException {
+        session.logout();
+    }
+
+    public boolean next() throws SQLException {
+        if (rows.hasNext()) {
+            try {
+                values = rows.nextRow().getValues();
+            } catch (RepositoryException e) {
+                SQLException exception =
+                    new SQLException("Unable to retrieve a row");
+                exception.initCause(e);
+                throw exception;
+            }
+            return true;
+        } else {
+            values = null;
+            return false;
+        }
+    }
+
+
+    public boolean first() throws SQLException {
+        throw new SQLFeatureNotSupportedException("ResultSet.first");
+    }
+
+    public boolean absolute(int row) throws SQLException {
+        throw new SQLFeatureNotSupportedException("ResultSet.absolute");
+    }
+
+    public void afterLast() throws SQLException {
+        throw new SQLFeatureNotSupportedException("ResultSet.afterLast");
+    }
+
+    public void beforeFirst() throws SQLException {
+        throw new SQLFeatureNotSupportedException("ResultSet.beforeFirst");
+    }
+
+    public void cancelRowUpdates() throws SQLException {
+    }
+
+    public void clearWarnings() throws SQLException {
+    }
+
+    public void deleteRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("ResultSet.deleteRow");
+    }
+
+    public int findColumn(String columnLabel) throws SQLException {
+        for (int i = 0; i < names.length; i++) {
+            if (names[i].equals(columnLabel)) {
+                return i + 1;
+            }
+        }
+        throw new SQLException("Column not found: " + columnLabel);
+    }
+
+    public Array getArray(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("ResultSet.getArray");
+    }
+
+    public Array getArray(String columnLabel) throws SQLException {
+        return getArray(findColumn(columnLabel));
+    }
+
+    public InputStream getAsciiStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("ResultSet.getAsciiStream");
+    }
+
+    public InputStream getAsciiStream(String columnLabel) throws SQLException {
+        return getAsciiStream(findColumn(columnLabel));
+    }
+
+    private SQLException newSQLException(String message, Throwable cause) {
+        SQLException exception = new SQLException(message);
+        exception.initCause(cause);
+        return exception;
+    }
+
+    private Value getValue(int column) throws SQLException {
+        if (values == null) {
+            throw new SQLException("No current row");
+        } else if (column < 1 && column > values.length) {
+            throw new SQLException("Invalid column: " + column);
+        } else {
+            return values[column - 1];
+        }
+    }
+
+    public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            if (value.getType() == PropertyType.LONG) {
+                return new BigDecimal(value.getLong());
+            } else {
+                return new BigDecimal(value.getDouble());
+            }
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+        return getBigDecimal(findColumn(columnLabel));
+    }
+
+    public BigDecimal getBigDecimal(int columnIndex, int scale)
+            throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public BigDecimal getBigDecimal(String columnLabel, int scale)
+            throws SQLException {
+        return getBigDecimal(findColumn(columnLabel), scale);
+    }
+
+    public InputStream getBinaryStream(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return value.getStream();
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public InputStream getBinaryStream(String columnLabel) throws SQLException {
+        return getBinaryStream(findColumn(columnLabel));
+    }
+
+    public Blob getBlob(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Blob getBlob(String columnLabel) throws SQLException {
+        return getBlob(findColumn(columnLabel));
+    }
+
+    public boolean getBoolean(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return value.getBoolean();
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public boolean getBoolean(String columnLabel) throws SQLException {
+        return getBoolean(findColumn(columnLabel));
+    }
+
+    public byte getByte(int columnIndex) throws SQLException {
+        return (byte) getLong(columnIndex);
+    }
+
+    public byte getByte(String columnLabel) throws SQLException {
+        return getByte(findColumn(columnLabel));
+    }
+
+    public byte[] getBytes(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public byte[] getBytes(String columnLabel) throws SQLException {
+        return getBytes(findColumn(columnLabel));
+    }
+
+    public Reader getCharacterStream(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return new InputStreamReader(value.getStream(), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw newSQLException("UTF-8 is not supported", e);
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public Reader getCharacterStream(String columnLabel) throws SQLException {
+        return getCharacterStream(findColumn(columnLabel));
+    }
+
+    public Clob getClob(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Clob getClob(String columnLabel) throws SQLException {
+        return getClob(findColumn(columnLabel));
+    }
+
+    public int getConcurrency() throws SQLException {
+        return CONCUR_READ_ONLY;
+    }
+
+    public String getCursorName() throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Date getDate(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return new Date(value.getDate().getTimeInMillis());
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public Date getDate(String columnLabel) throws SQLException {
+        return getDate(findColumn(columnLabel));
+    }
+
+    public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+        return getDate(findColumn(columnLabel), cal);
+    }
+
+    public double getDouble(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return value.getDouble();
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public double getDouble(String columnLabel) throws SQLException {
+        return getDouble(findColumn(columnLabel));
+    }
+
+    public int getFetchDirection() throws SQLException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public int getFetchSize() throws SQLException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public float getFloat(int columnIndex) throws SQLException {
+        return (float) getDouble(columnIndex);
+    }
+
+    public float getFloat(String columnLabel) throws SQLException {
+        return getFloat(findColumn(columnLabel));
+    }
+
+    public int getHoldability() throws SQLException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public int getInt(int columnIndex) throws SQLException {
+        return (int) getLong(columnIndex);
+    }
+
+    public int getInt(String columnLabel) throws SQLException {
+        return getInt(findColumn(columnLabel));
+    }
+
+    public long getLong(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return value.getLong();
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public long getLong(String columnLabel) throws SQLException {
+        return getLong(findColumn(columnLabel));
+    }
+
+    public ResultSetMetaData getMetaData() throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Reader getNCharacterStream(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Reader getNCharacterStream(String columnLabel) throws SQLException {
+        return getNCharacterStream(findColumn(columnLabel));
+    }
+
+    public NClob getNClob(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NClob getNClob(String columnLabel) throws SQLException {
+        return getNClob(findColumn(columnLabel));
+    }
+
+    public String getNString(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getNString(String columnLabel) throws SQLException {
+        return getNString(findColumn(columnLabel));
+    }
+
+    public Object getObject(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object getObject(String columnLabel) throws SQLException {
+        return getObject(findColumn(columnLabel));
+    }
+
+    public Object getObject(int columnIndex, Map<String, Class<?>> map)
+            throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object getObject(String columnLabel, Map<String, Class<?>> map)
+            throws SQLException {
+        return getObject(findColumn(columnLabel), map);
+    }
+
+    public Ref getRef(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Ref getRef(String columnLabel) throws SQLException {
+        return getRef(findColumn(columnLabel));
+    }
+
+    public int getRow() throws SQLException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public RowId getRowId(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public RowId getRowId(String columnLabel) throws SQLException {
+        return getRowId(findColumn(columnLabel));
+    }
+
+    public SQLXML getSQLXML(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public SQLXML getSQLXML(String columnLabel) throws SQLException {
+        return getSQLXML(findColumn(columnLabel));
+    }
+
+    public short getShort(int columnIndex) throws SQLException {
+        return (short) getLong(columnIndex);
+    }
+
+    public short getShort(String columnLabel) throws SQLException {
+        return getShort(findColumn(columnLabel));
+    }
+
+    public Statement getStatement() throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getString(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return value.getString();
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public String getString(String columnLabel) throws SQLException {
+        return getString(findColumn(columnLabel));
+    }
+
+    public Time getTime(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return new Time(value.getDate().getTimeInMillis());
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public Time getTime(String columnLabel) throws SQLException {
+        return getTime(findColumn(columnLabel));
+    }
+
+    public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+        return getTime(findColumn(columnLabel), cal);
+    }
+
+    public Timestamp getTimestamp(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return new Timestamp(value.getDate().getTimeInMillis());
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public Timestamp getTimestamp(String columnLabel) throws SQLException {
+        return getTimestamp(findColumn(columnLabel));
+    }
+
+    public Timestamp getTimestamp(int columnIndex, Calendar cal)
+            throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Timestamp getTimestamp(String columnLabel, Calendar cal)
+            throws SQLException {
+        return getTimestamp(findColumn(columnLabel), cal);
+    }
+
+    public int getType() throws SQLException {
+        return TYPE_FORWARD_ONLY;
+    }
+
+    public URL getURL(int columnIndex) throws SQLException {
+        Value value = getValue(columnIndex);
+        try {
+            return new URL(value.getString());
+        } catch (MalformedURLException e) {
+            throw newSQLException("Invalid URL: " + value, e);
+        } catch (RepositoryException e) {
+            throw newSQLException("Invalid value: " + value, e);
+        }
+    }
+
+    public URL getURL(String columnLabel) throws SQLException {
+        return getURL(findColumn(columnLabel));
+    }
+
+    public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public InputStream getUnicodeStream(String columnLabel) throws SQLException {
+        return getUnicodeStream(findColumn(columnLabel));
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        return null;
+    }
+
+    public void insertRow() throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean isAfterLast() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isBeforeFirst() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isClosed() throws SQLException {
+        return !session.isLive();
+    }
+
+    public boolean isFirst() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isLast() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean last() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void moveToCurrentRow() throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void moveToInsertRow() throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean previous() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void refreshRow() throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean relative(int rows) throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean rowDeleted() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean rowInserted() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean rowUpdated() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void setFetchDirection(int direction) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setFetchSize(int rows) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateArray(int columnIndex, Array x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateArray(String columnLabel, Array x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateAsciiStream(int columnIndex, InputStream x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateAsciiStream(String columnLabel, InputStream x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateAsciiStream(int columnIndex, InputStream x, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateAsciiStream(String columnLabel, InputStream x, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateAsciiStream(int columnIndex, InputStream x, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateAsciiStream(String columnLabel, InputStream x, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBigDecimal(int columnIndex, BigDecimal x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBigDecimal(String columnLabel, BigDecimal x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBinaryStream(int columnIndex, InputStream x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBinaryStream(String columnLabel, InputStream x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBinaryStream(int columnIndex, InputStream x, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBinaryStream(String columnLabel, InputStream x, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBinaryStream(int columnIndex, InputStream x, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBinaryStream(String columnLabel, InputStream x,
+            long length) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBlob(int columnIndex, Blob x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBlob(String columnLabel, Blob x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBlob(int columnIndex, InputStream inputStream)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBlob(String columnLabel, InputStream inputStream)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBlob(int columnIndex, InputStream inputStream, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBlob(String columnLabel, InputStream inputStream,
+            long length) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBoolean(String columnLabel, boolean x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateByte(int columnIndex, byte x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateByte(String columnLabel, byte x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateBytes(String columnLabel, byte[] x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateCharacterStream(int columnIndex, Reader x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateCharacterStream(String columnLabel, Reader reader)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateCharacterStream(int columnIndex, Reader x, int length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateCharacterStream(String columnLabel, Reader reader,
+            int length) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateCharacterStream(int columnIndex, Reader x, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateCharacterStream(String columnLabel, Reader reader,
+            long length) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateClob(int columnIndex, Clob x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateClob(String columnLabel, Clob x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateClob(int columnIndex, Reader reader) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateClob(String columnLabel, Reader reader)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateClob(int columnIndex, Reader reader, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateClob(String columnLabel, Reader reader, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateDate(int columnIndex, Date x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateDate(String columnLabel, Date x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateDouble(int columnIndex, double x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateDouble(String columnLabel, double x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateFloat(int columnIndex, float x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateFloat(String columnLabel, float x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateInt(int columnIndex, int x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateInt(String columnLabel, int x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateLong(int columnIndex, long x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateLong(String columnLabel, long x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNCharacterStream(int columnIndex, Reader x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNCharacterStream(String columnLabel, Reader reader)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNCharacterStream(int columnIndex, Reader x, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNCharacterStream(String columnLabel, Reader reader,
+            long length) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNClob(int columnIndex, NClob clob) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNClob(String columnLabel, NClob clob) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNClob(int columnIndex, Reader reader) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNClob(String columnLabel, Reader reader)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNClob(int columnIndex, Reader reader, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNClob(String columnLabel, Reader reader, long length)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNString(int columnIndex, String string)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNString(String columnLabel, String string)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNull(int columnIndex) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateNull(String columnLabel) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateObject(int columnIndex, Object x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateObject(String columnLabel, Object x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateObject(int columnIndex, Object x, int scaleOrLength)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateObject(String columnLabel, Object x, int scaleOrLength)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateRef(int columnIndex, Ref x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateRef(String columnLabel, Ref x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateRow() throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateRowId(int columnIndex, RowId x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateRowId(String columnLabel, RowId x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateSQLXML(int columnIndex, SQLXML xmlObject)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateSQLXML(String columnLabel, SQLXML xmlObject)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateShort(int columnIndex, short x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateShort(String columnLabel, short x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateString(int columnIndex, String x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateString(String columnLabel, String x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateTime(int columnIndex, Time x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateTime(String columnLabel, Time x) throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateTimestamp(int columnIndex, Timestamp x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void updateTimestamp(String columnLabel, Timestamp x)
+            throws SQLException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean wasNull() throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/JCRResultSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/TpsReport.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/TpsReport.java?rev=724803&r1=724802&r2=724803&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/TpsReport.java (original)
+++ jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/main/java/org/apache/jackrabbit/jdbc/TpsReport.java Tue Dec  9 10:12:46 2008
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.jdbc;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.Statement;
@@ -67,7 +66,7 @@
      * for any kind of report.
      */
     void initDatabase() throws Exception {
-        Connection conn = openConnection();
+        Connection conn = Fixture.getH2Connection();
         Statement stat = conn.createStatement();
         stat.execute("CREATE ALIAS IF NOT EXISTS " + 
             "TPS_REPORT FOR \"" + getClass().getName() + ".getTpsReport\"");
@@ -80,26 +79,15 @@
      * reporting tool such as Crystal Reports.
      */
     void runQuery() throws Exception {
-        Connection conn = openConnection();
+        Connection conn = Fixture.getH2Connection();
         Statement stat = conn.createStatement();
         ResultSet rs = stat.executeQuery(
             "SELECT * FROM TPS_REPORT('admin', 'admin')");
         while(rs.next()) {
             System.out.print(rs.getString(1));
         }
-        conn.close();
     }
-    
-    /**
-     * Open a connection to a temporary database.
-     * 
-     * @return the connection
-     */
-    private static Connection openConnection() throws Exception {
-        Class.forName("org.h2.Driver");
-        return DriverManager.getConnection("jdbc:h2:~/jcr", "sa", "sa");
-    }
-    
+
     /**
      * This method opens a JCR session and run the XPath query '//test' against
      * the JCR repository. This method will also convert the JCR QueryResult to

Modified: jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/test/java/org/apache/jackrabbit/jdbc/Fixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/test/java/org/apache/jackrabbit/jdbc/Fixture.java?rev=724803&r1=724802&r2=724803&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/test/java/org/apache/jackrabbit/jdbc/Fixture.java (original)
+++ jackrabbit/sandbox/jackrabbit-jdbc2jcr/src/test/java/org/apache/jackrabbit/jdbc/Fixture.java Tue Dec  9 10:12:46 2008
@@ -19,6 +19,7 @@
 import java.io.File;
 import java.sql.Connection;
 import java.sql.DriverManager;
+import java.sql.SQLException;
 
 import javax.jcr.Node;
 import javax.jcr.Repository;
@@ -88,9 +89,13 @@
     @AfterSuite
     public void tearDownRepository() throws Exception {
         derbyConnection.close();
-        DriverManager.getConnection(
-                "jdbc:derby:" + new File(directory, "derby").getPath()
-                + ";shutdown=true");
+        try {
+            DriverManager.getConnection(
+                    "jdbc:derby:" + new File(directory, "derby").getPath()
+                    + ";shutdown=true");
+        } catch (SQLException e) {
+            // ignore
+        }
 
         h2Connection.close();