db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r587652 [5/6] - in /db/derby/code/trunk: ./ java/demo/ java/demo/vtis/ java/demo/vtis/data/ java/demo/vtis/java/ java/demo/vtis/java/org/ java/demo/vtis/java/org/apache/ java/demo/vtis/java/org/apache/derbyDemo/ java/demo/vtis/java/org/apac...
Date Tue, 23 Oct 2007 20:54:07 GMT
Propchange: db/derby/code/trunk/java/demo/vtis/data/svn_log.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/FlatFileVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/FlatFileVTI.java?rev=587652&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/FlatFileVTI.java (added)
+++ db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/FlatFileVTI.java Tue Oct 23 13:54:05 2007
@@ -0,0 +1,223 @@
+/*
+
+Derby - Class org.apache.derbyDemo.vtis.core.FlatFileVTI
+
+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.derbyDemo.vtis.core;
+
+import java.io.*;
+import java.math.BigDecimal;
+import java.sql.*;
+import java.text.DateFormat;
+import java.text.ParseException;
+
+/**
+ * <p>
+ * This VTI makes a table out of the records in a flat file. This is an abstract
+ * class. Child classes are responsible for implementing the following methods
+ * which parse and advance the file:
+ * </p>
+ *
+ * <ul>
+ * <li>parseRow() - Parses the next record of the file into an array of Strings,
+ * one for each column.</li>
+ * </ul>
+ */
+public    abstract  class   FlatFileVTI  extends StringColumnVTI
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private String              _textFileName;
+
+    private File                _file;
+    private FileReader          _fileReader;
+    private LineNumberReader    _lineReader;
+
+    private boolean             _closed = false;
+
+    private String[]            _row;
+
+    private int                 _lineNumber = -1;
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // FlatFileVTI BEHAVIOR TO BE IMPLEMENTED BY SUBCLASSES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Parse the next chunk of text, using readLine(), and return the next row.
+     * Returns null if the file is exhausted.
+     * </p>
+     */
+    protected  abstract String[]  parseRow( ) throws SQLException;
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // StringColumnVTI BEHAVIOR TO BE IMPLEMENTED BY SUBCLASSES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Get the string value of the column in the current row identified by the 1-based columnNumber.
+     * </p>
+     */
+    protected  String  getRawColumn( int columnNumber ) throws SQLException
+    {
+        return _row[ columnNumber - 1 ];
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTORS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Build a StringColumnVTI with the given column names
+     * </p>
+     */
+    public  FlatFileVTI( String[] columnNames, String textFileName )
+    {
+        super( columnNames );
+
+        _textFileName = textFileName;
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // ResultSet BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public  boolean next() throws SQLException
+    {
+        if ( _file == null )
+        {
+            try {
+                _file = new File( _textFileName );
+                _fileReader = new FileReader( _file );
+                _lineReader = new LineNumberReader( _fileReader );
+            } catch (Throwable t) { throw wrap( t ); }
+        }
+
+        _row = parseRow();
+
+        if ( _row == null ) { return false; }
+        else { return true; }
+    }
+
+    public  void close() throws SQLException
+    {
+        try {
+            if ( _lineReader != null ) { _lineReader.close(); }
+            if ( _fileReader != null ) { _fileReader.close(); }
+
+        } catch (Throwable t) { throw wrap( t ); }
+        finally
+        {
+             _lineReader = null;
+             _fileReader = null;
+            _file = null;
+        }
+    }
+
+    public  ResultSetMetaData   getMetaData() throws SQLException
+    {
+        throw new SQLException( "Not implemented." );
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // MINIONS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Get the current line number.
+     * </p>
+     */
+    protected   int getLineNumber() { return _lineNumber; }
+    
+    /**
+     * <p>
+     * Get the name of the file being read.
+     * </p>
+     */
+    protected   String getTextFileName() { return _textFileName; }
+    
+    /**
+     * <p>
+     * Read the next line from the file and return it. Return null if the file
+     * is exhausted.
+     * </p>
+     */
+    protected   String  readLine()  throws SQLException
+    {
+        try {
+            String retval = _lineReader.readLine();
+
+            _lineNumber++;
+            return retval;
+        } catch( Throwable t ) { throw wrap( t ); }
+    }
+
+    /**
+     * <p>
+     * Wrap an exception in a SQLException.
+     * </p>
+     */
+    protected SQLException    wrap( Throwable t )
+    {
+        SQLException    se = new SQLException( t.getMessage() );
+
+        se.initCause( t );
+
+        return se;
+    }
+
+    /**
+     * <p>
+     * Wrap an exception in a SQLException.
+     * </p>
+     */
+    protected SQLException    wrap( String message, Throwable t )
+    {
+        SQLException    se = new SQLException( message );
+
+        se.initCause( t );
+
+        return se;
+    }
+
+}

Propchange: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/FlatFileVTI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryRow.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryRow.java?rev=587652&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryRow.java (added)
+++ db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryRow.java Tue Oct 23 13:54:05 2007
@@ -0,0 +1,54 @@
+/*
+
+Derby - Class org.apache.derbyDemo.vtis.core.QueryRow
+
+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.derbyDemo.vtis.core;
+
+import java.lang.annotation.*;
+
+/**
+ * <p>
+ * This is an Annotation describing the query needed to materialize a ResultSet
+ * from a foreign database.
+ * </p>
+ *
+  */
+@Retention( value=RetentionPolicy.RUNTIME )
+public  @interface  QueryRow
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /** The name of the JDBC driver used to access the external DB */
+    String      jdbcDriverName();
+
+    /** The query string that is passed to the foreign database */
+    String      query();
+    
+}

Propchange: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryRow.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryVTIHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryVTIHelper.java?rev=587652&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryVTIHelper.java (added)
+++ db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryVTIHelper.java Tue Oct 23 13:54:05 2007
@@ -0,0 +1,389 @@
+/*
+
+Derby - Class org.apache.derbyDemo.vtis.core.QueryVTIHelper
+
+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.derbyDemo.vtis.core;
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.sql.*;
+import java.util.*;
+
+/**
+ * <p>
+ * This is a set of helper methods executing a query against an external database. This
+ * class maintains a cache of connections to external databases. Each connection
+ * is identified by its connection URL. In addition to materializing external
+ * data sets, this class provides a database procedure for closing an external connection.
+ * </p>
+ *
+  */
+public  abstract    class   QueryVTIHelper
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private static  Hashtable<String,Connection>    _openConnections = new Hashtable<String,Connection>();
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTORS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // DATABASE PROCEDURES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Register this method as a database procedure, then use it to register
+     * all of the QueryRow table functions in a class.
+     * </p>
+     */
+    public  static  void  registerQueryRowVTIs( String className, String connectionURL )
+        throws Exception
+    {
+        // find public static methods which return ResultSet
+        Class           theClass = Class.forName( className );
+        Method[]        methods = theClass.getMethods();
+        int             count = methods.length;
+        Method          candidate = null;
+        QueryRow        queryRowAnnotation = null;
+
+        for ( int i = 0; i < count; i++ )
+        {
+            candidate = methods[ i ];
+
+            int         modifiers = candidate.getModifiers();
+
+            if (
+                Modifier.isPublic( modifiers ) &&
+                Modifier.isStatic( modifiers ) &&
+                candidate.getReturnType() == ResultSet.class
+                )
+            {
+                queryRowAnnotation = candidate.getAnnotation( QueryRow.class );
+
+                if ( queryRowAnnotation != null )
+                {
+                    VTIHelper.unregisterVTI( candidate );
+                    
+                    registerVTI
+                        (
+                         candidate,
+                         queryRowAnnotation.jdbcDriverName(),
+                         connectionURL,
+                         queryRowAnnotation.query(),
+                         new String[] {}
+                         );
+                }
+            }            
+        }
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // PUBLIC BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Close the connection associated with an URL.
+     * </p>
+     */
+    public  static  void closeConnection( String connectionURL )
+        throws SQLException
+    {
+        Connection      conn = _openConnections.get( connectionURL );
+
+        if ( conn != null ) { conn.close(); }
+
+        _openConnections.remove( connectionURL );
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // PUBLIC BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Register a method as a Derby Table Function. We assume the following:
+     * </p>
+     *
+     * <ul>
+     * <li>The method is public and static.</li>
+     * <li>The method returns a ResultSet.</li>
+     * </ul>
+     *
+     */
+    public  static  void  registerVTI
+        ( Method method, String jdbcDriverName, String connectionURL, String query, String[] queryArgs )
+        throws Exception
+    {
+        QueryRow            annotation = method.getAnnotation( QueryRow.class );
+        ResultSet           rs = instantiateVTI( jdbcDriverName, connectionURL, query, queryArgs );
+        ResultSetMetaData   rsmd = rs.getMetaData();
+        String[]            columnNames = getColumnNames( rsmd );
+        String[]            columnTypes = getColumnTypes( rsmd );
+
+        VTIHelper.registerVTI( method, columnNames, columnTypes, true );
+
+        rs.close();
+    }
+    
+    /**
+     * <p>
+     * Create a VTI ResultSet. It is assumed that our caller is a
+     * QueryRow-annotated method with no arguments.
+     * </p>
+     *
+     */
+    public  static  ResultSet  instantiateQueryRowVTI( String connectionURL )
+        throws SQLException
+    {
+        QueryRow          annotation = null;
+        
+        try {
+            // look up the method on top of us
+            StackTraceElement[]     stack = (new Throwable()).getStackTrace();
+            StackTraceElement       caller = stack[ 1 ];
+            Class                   callerClass = Class.forName( caller.getClassName() );
+            String                  methodName = caller.getMethodName();
+            Method                  method = callerClass.getMethod
+                ( methodName, new Class[] { String.class } );
+            
+            annotation = method.getAnnotation( QueryRow.class );
+        } catch (Throwable t) { throw new SQLException( t.getMessage() ); }
+
+        String              jdbcDriverName = annotation.jdbcDriverName();
+        String              query = annotation.query();
+
+        return instantiateVTI( jdbcDriverName, connectionURL, query, new String[] {} );
+    }
+    
+    /**
+     * <p>
+     * Create an external ResultSet given a driver, a connection url, and a query.
+     * </p>
+     *
+     */
+    public static  ResultSet  instantiateVTI( String jdbcDriverName, String connectionURL, String query, String[] queryArgs )
+        throws SQLException
+    {
+        Connection      conn = getConnection( jdbcDriverName, connectionURL );
+        int             count = 0;
+
+        if ( queryArgs != null ) { count = queryArgs.length; }
+
+        VTIHelper.print( query );
+        
+        PreparedStatement           ps = conn.prepareStatement( query );
+        //ParameterMetaData           pmd = ps.getParameterMetaData();
+
+        for ( int i = 0; i < count; i++ )
+        {
+            String      arg = queryArgs[ i ];
+            int         param = i + 1;
+
+            if ( arg == null )
+            {
+                VTIHelper.print( "Setting parameter " + param + " to null" );
+                //ps.setNull( param, pmd.getParameterType( param ) );
+                ps.setNull( param, Types.VARCHAR );
+            }
+            else {
+                VTIHelper.print( "Setting parameter " + param + " to " + arg );
+                ps.setString( param, arg );
+            }
+        }
+
+        return ps.executeQuery();
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // MINIONS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Get the column names from an external ResultSet.
+     * </p>
+     *
+     */
+    private static  String[]    getColumnNames( ResultSetMetaData rsmd )
+        throws SQLException
+    {
+        int                     columnCount = rsmd.getColumnCount();
+        String[]            columnNames = new String[ columnCount ];
+
+        for ( int i = 0; i < columnCount; i++ ) { columnNames[ i ] = rsmd.getColumnName( i + 1 ); }
+
+        return columnNames;
+    }
+
+    /**
+     * <p>
+     * Get the column types from an external ResultSet.
+     * </p>
+     *
+     */
+    private static  String[]    getColumnTypes( ResultSetMetaData rsmd )
+        throws SQLException
+    {
+        int                     columnCount = rsmd.getColumnCount();
+        String[]            columnTypes = new String[ columnCount ];
+
+        for ( int i = 0; i < columnCount; i++ )
+        { columnTypes[ i ] = getColumnType( rsmd, i + 1 ); }
+
+        return columnTypes;
+    }
+
+    /**
+     * <p>
+     * Get the type of an external database's column as a Derby type name.
+     * </p>
+     *
+     */
+    private static  String    getColumnType( ResultSetMetaData rsmd, int idx )
+        throws SQLException
+    {
+        int         jdbcType = rsmd.getColumnType( idx );
+        int         precision = rsmd.getPrecision( idx );
+        int         scale = rsmd.getScale( idx );
+
+        switch( jdbcType )
+        {
+        case    Types.BIGINT:                           return "bigint";
+        case    Types.BINARY:                           return "char " + precisionToLength( precision ) + "  for bit data";
+        case    Types.BIT:                                  return "smallint";
+        case    Types.BLOB:                             return "blob";
+        case    Types.BOOLEAN:                      return "smallint";
+        case    Types.CHAR:                             return "char" + precisionToLength( precision );
+        case    Types.CLOB:                             return "clob";
+        case    Types.DATE:                             return "date";
+        case    Types.DECIMAL:                      return "decimal" + precisionAndScale( precision, scale );
+        case    Types.DOUBLE:                       return "double";
+        case    Types.FLOAT:                            return "float";
+        case    Types.INTEGER:                      return "integer";
+        case    Types.LONGVARBINARY:        return "long varchar for bit data";
+        case    Types.LONGVARCHAR:          return "long varchar";
+        case    Types.NUMERIC:                      return "numeric" + precisionAndScale( precision, scale );
+        case    Types.REAL:                             return "real";
+        case    Types.SMALLINT:                     return "smallint";
+        case    Types.TIME:                             return "time";
+        case    Types.TIMESTAMP:                return "timestamp";
+        case    Types.TINYINT:                      return "smallint";
+        case    Types.VARBINARY:                return "varchar " + precisionToLength( precision ) + "  for bit data";
+        case    Types.VARCHAR:                      return "varchar" + precisionToLength( precision );
+ 
+        default:
+            throw new SQLException
+                ( "Unknown external data type. JDBC type = " + jdbcType + ", external type name = " + rsmd.getColumnTypeName( idx ) );
+        }
+    }
+
+    /**
+     * <p>
+     * Turns precision into a length designator.
+     * </p>
+     *
+     */
+    private static  String  precisionToLength( int precision )
+    {
+        return "( " + precision + " )";
+    }
+    
+    /**
+     * <p>
+     * Build a precision and scale designator.
+     * </p>
+     *
+     */
+    private static  String  precisionAndScale( int precision, int scale )
+    {
+        return "( " + precision + ", " + scale + " )";
+    }
+    
+    ///////////////////////////////////////////////////////////////
+    //
+    // CONNECTION MANAGEMENT MINIONS
+    //
+    ///////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Look up an open connection. If it doesn't exist, create a Connection.
+     * </p>
+     *
+     */
+    protected static  Connection  getConnection( String jdbcDriverName, String connectionURL )
+        throws SQLException
+    {
+        Connection      conn = _openConnections.get( connectionURL );
+        
+        if ( conn == null )
+        {
+            // as necessary, fault in the jdbc driver which accesses the external dbms
+
+            try {
+                Class.forName( jdbcDriverName );
+            }
+            catch (ClassNotFoundException e)
+            {
+                throw new SQLException( "Could not find " + jdbcDriverName + " on the classpath." );
+            }
+            
+            try {
+                conn = DriverManager.getConnection( connectionURL );
+                _openConnections.put( connectionURL, conn );
+            }
+            catch (SQLException s)
+            {
+                SQLException    t = new SQLException( "Could not open a connection to " + connectionURL + ". Perhaps the foreign database is not up and running? Details: " + s.getMessage() );
+
+                t.setNextException( s );
+
+                throw t;
+            }
+        }
+
+        return conn;
+    }
+    
+ 
+}

Propchange: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryVTIHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/StringColumnVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/StringColumnVTI.java?rev=587652&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/StringColumnVTI.java (added)
+++ db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/StringColumnVTI.java Tue Oct 23 13:54:05 2007
@@ -0,0 +1,567 @@
+/*
+
+Derby - Class org.apache.derbyDemo.vtis.core.StringColumnVTI
+
+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.derbyDemo.vtis.core;
+
+import java.io.*;
+import java.math.BigDecimal;
+import java.sql.*;
+import java.text.DateFormat;
+import java.text.ParseException;
+
+/**
+ * <p>
+ * This is an abstract VTI which assumes that all columns are strings and which
+ * coerces the strings to reasonable values for various getXXX()
+ * methods. Subclasses must implement the following ResultSet methods:
+ * </p>
+ *
+ * <ul>
+ * <li>next( )</li>
+ * <li>close()</li>
+ * <li>getMetaData()</li>
+ * </ul>
+ *
+ * <p>
+ * and the following protected methods introduced by this class:
+ * </p>
+ *
+ * <ul>
+ * <li>getRawColumn( int columnNumber )</li>
+ * </ul>
+ */
+public  abstract    class   StringColumnVTI extends VTITemplate
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // INNER CLASSES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * A crude Blob implementation.
+     * </p>
+     */
+    public	static	final	class	SimpleBlob	implements	Blob
+    {
+        private	byte[]	_bytes;
+        
+        public	SimpleBlob( byte[] bytes )
+        {
+            _bytes = bytes;
+        }
+        
+        public	InputStream	getBinaryStream()
+        {
+            return new ByteArrayInputStream( _bytes );
+        }
+        
+        public	byte[]	getBytes( long position, int length ) { return _bytes; }
+        
+        public	long	length()
+        {
+            if ( _bytes == null ) { return 0L; }
+            return (long) _bytes.length;
+        }
+        
+        public	long	position( Blob pattern, long start ) { return 0L; }
+        public	long	position( byte[] pattern, long start ) { return 0L; }
+        
+        public	boolean	equals( Object other )
+        {
+            if ( other == null ) { return false; }
+            if ( !( other instanceof Blob ) ) { return false; }
+            
+            Blob	that = (Blob) other;
+            
+            try {
+                if ( this.length() != that.length() ) { return false; }
+                
+                InputStream	thisStream = this.getBinaryStream();
+                InputStream	thatStream = that.getBinaryStream();
+                
+                while( true )
+                {
+                    int		nextByte = thisStream.read();
+                    
+                    if ( nextByte < 0 ) { break; }
+                    if ( nextByte != thatStream.read() ) { return false; }
+                }
+            }
+            catch (Exception e)
+            {
+                System.err.println( e.getMessage() );
+                e.printStackTrace();
+                return false;
+            }
+            
+            return true;
+        }
+        
+        public int setBytes(long arg0, byte[] arg1) throws SQLException {
+            throw new SQLException("not implemented");
+        }
+        
+        public int setBytes(long arg0, byte[] arg1, int arg2, int arg3) throws SQLException {
+            throw new SQLException("not implemented");
+        }
+
+        public OutputStream setBinaryStream(long arg0) throws SQLException {
+            throw new SQLException("not implemented");
+        }
+
+        public void truncate(long arg0) throws SQLException {
+            throw new SQLException("not implemented");
+        }
+    }
+    
+    /**
+     * <p>
+     * A crude Clob implementation.
+     * </p>
+     */
+    public	static	final	class	SimpleClob	implements	Clob
+    {
+        private	String	_contents;
+
+        public	SimpleClob( String contents )
+        {
+            _contents = contents;
+        }
+        
+        public	InputStream	getAsciiStream()
+        {
+            try {
+                return new ByteArrayInputStream( _contents.getBytes( "UTF-8" ) );
+            }
+            catch (Exception e) { return null; }
+        }
+        
+        public	Reader	getCharacterStream()
+        {
+            return new CharArrayReader( _contents.toCharArray() );
+        }
+        
+        public	String	getSubString( long position, int length )
+        {
+            return _contents.substring( (int) position, length );
+        }
+		
+        public	long	length()
+        {
+            if ( _contents == null ) { return 0L; }
+            return (long) _contents.length();
+        }
+        
+        public	long	position( Clob searchstr, long start ) { return 0L; }
+        public	long	position( String searchstr, long start ) { return 0L; }
+        
+        public	boolean	equals( Object other )
+        {
+            if ( other == null ) { return false; }
+            if ( !( other instanceof Clob ) ) { return false; }
+            
+            Clob	that = (Clob) other;
+            
+            try {
+                if ( this.length() != that.length() ) { return false; }
+                
+                InputStream	thisStream = this.getAsciiStream();
+                InputStream	thatStream = that.getAsciiStream();
+                
+                while( true )
+                {
+                    int		nextByte = thisStream.read();
+                    
+                    if ( nextByte < 0 ) { break; }
+                    if ( nextByte != thatStream.read() ) { return false; }
+                }
+            }
+            catch (Exception e)
+            {
+                System.err.println( e.getMessage() );
+                e.printStackTrace();
+                return false;
+            }
+            
+            return true;
+        }
+        
+        public int setString(long arg0, String arg1) throws SQLException {
+            throw new SQLException("not implemented");
+        }
+        
+        public int setString(long arg0, String arg1, int arg2, int arg3) throws SQLException {
+            throw new SQLException("not implemented");
+        }
+
+        public OutputStream setAsciiStream(long arg0) throws SQLException {
+            throw new SQLException("not implemented");
+        }
+
+        public Writer setCharacterStream(long arg0) throws SQLException {
+            throw new SQLException("not implemented");
+        }
+
+        public void truncate(long arg0) throws SQLException {
+            throw new SQLException("not implemented");    
+        }
+
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private String[]      _columnNames;
+    private boolean _lastColumnWasNull;
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // StringColumnVTI BEHAVIOR TO BE IMPLEMENTED BY SUBCLASSES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Get the string value of the column in the current row identified by the 1-based columnNumber.
+     * </p>
+     */
+    protected  abstract    String  getRawColumn( int columnNumber ) throws SQLException;
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTORS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Build a StringColumnVTI with the given column names
+     * </p>
+     */
+    public  StringColumnVTI( String[] columnNames )
+    {
+        _columnNames = columnNames;
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // ResultSet BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public boolean wasNull() throws SQLException { return _lastColumnWasNull; }
+    
+    public int findColumn( String columnName ) throws SQLException
+    {
+        int     count = _columnNames.length;
+
+        for ( int i = 0; i < count; i++ ) { if ( _columnNames[ i ].equals( columnName ) ) { return i+1; } }
+
+        throw new SQLException( "Unknown column name." );
+    }
+    
+    public String getString(int columnIndex) throws SQLException
+    {
+        String  columnValue = getRawColumn( columnIndex );
+
+        checkNull( columnValue );
+
+        return columnValue;
+    }
+    
+    public boolean getBoolean(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return false; }
+        else { return Boolean.valueOf( columnValue ).booleanValue(); }
+    }
+
+    public byte getByte(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return (byte) 0; }
+        else
+        {
+            try {
+                return Byte.valueOf( columnValue ).byteValue();
+            } catch (NumberFormatException e) { throw wrap( e ); }
+        }
+    }
+
+    public short getShort(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return (short) 0; }
+        else
+        {
+            try {
+                return Short.valueOf( columnValue ).shortValue();
+            } catch (NumberFormatException e) { throw wrap( e ); }
+        }
+    }
+
+    public int getInt(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return 0; }
+        else
+        {
+            try {
+                return Integer.valueOf( columnValue ).intValue();
+            } catch (NumberFormatException e) { throw wrap( e ); }
+        }
+    }
+
+    public long getLong(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return (long) 0; }
+        else
+        {
+            try {
+                return Long.valueOf( columnValue ).longValue();
+            } catch (NumberFormatException e) { throw wrap( e ); }
+        }
+    }
+
+   public float getFloat(int columnIndex) throws SQLException
+   {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return (float) 0; }
+        else
+        {
+            try {
+                return Float.valueOf( columnValue ).floatValue();
+            } catch (NumberFormatException e) { throw wrap( e ); }
+        }
+    }
+
+    public double getDouble(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return (double) 0; }
+        else
+        {
+            try {
+                return Double.valueOf( columnValue ).doubleValue();
+            } catch (NumberFormatException e) { throw wrap( e ); }
+        }
+    }
+
+    public BigDecimal getBigDecimal(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return null; }
+        else
+        {
+            try {
+                return new BigDecimal( columnValue );
+            } catch (NumberFormatException e) { throw wrap( e ); }
+        }
+    }
+
+    public byte[] getBytes(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return null; }
+        else
+        {
+            return columnValue.getBytes();
+        }
+    }
+
+    public java.sql.Date getDate(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return null; }
+        else
+        {
+            return new Date( parseDateTime( columnValue ) );
+        }
+    }
+
+    public java.sql.Time getTime(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return null; }
+        else
+        {
+            return new Time( parseDateTime( columnValue ) );
+        }
+    }
+
+    public java.sql.Timestamp getTimestamp(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return null; }
+        else
+        {
+            return new Timestamp( parseDateTime( columnValue ) );
+        }
+    }
+
+    public InputStream getAsciiStream(int columnIndex) throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        return getEncodedStream( columnValue, "US-ASCII" );
+    }
+
+    public java.io.InputStream getBinaryStream(int columnIndex)
+        throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return null; }
+        else { return new ByteArrayInputStream( getBytes( columnIndex ) ); }
+    }
+
+    public Blob getBlob(int columnIndex)
+        throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return null; }
+        else { return new SimpleBlob( getBytes( columnIndex ) ); }
+    }
+    
+    public Clob getClob(int columnIndex)
+        throws SQLException
+    {
+        String  columnValue = getString( columnIndex );
+
+        if ( columnValue == null ) { return null; }
+        { return new SimpleClob( getString( columnIndex ) ); }
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // PROTECTED BEHAVIOR USED BY SUBCLASSES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Return the names of the columns.
+     * </p>
+     */
+    protected   String[]    getColumnNames( )
+    {
+        return _columnNames;
+    }
+    
+    /**
+     * <p>
+     * Set the wasNull flag.
+     * </p>
+     */
+    protected   void setWasNull()
+    {
+        _lastColumnWasNull = true;
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // PRIVATE MINIONS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Set the wasNull flag based on whether this column value turned out to be null.
+     * </p>
+     */
+    private void checkNull( String columnValue )
+    {
+        _lastColumnWasNull = ( columnValue == null );
+    }
+    
+    /**
+     * <p>
+     * Wrap an exception in a SQLException.
+     * </p>
+     */
+    private SQLException wrap( Throwable t )
+    {
+        return new SQLException( t.getMessage() );
+    }
+    
+    /**
+     * <p>
+     * Translate a date/time expression into the corresponding long number of
+     * milliseconds.
+     * </p>
+     */
+    private long parseDateTime( String columnValue  )
+        throws SQLException
+    {
+        try {
+            DateFormat      df = DateFormat.getDateTimeInstance();
+                
+            java.util.Date  rawDate = df.parse( columnValue );
+
+            return rawDate.getTime();
+        } catch (ParseException e) { throw wrap( e ); }
+    }
+    
+    /**
+     * <p>
+     * Turn a string into an appropriately encoded ByteArrayInputStream.
+     * </p>
+     */
+    private InputStream getEncodedStream( String columnValue, String encoding  )
+        throws SQLException
+    {
+        if ( columnValue == null ) { return null; }
+        else
+        {
+            try {
+                byte[]      rawBytes = columnValue.getBytes( encoding );
+            
+                return new ByteArrayInputStream( rawBytes );
+            } catch (UnsupportedEncodingException e) { throw wrap( e ); }
+        }
+    }
+
+}

Propchange: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/StringColumnVTI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTIHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTIHelper.java?rev=587652&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTIHelper.java (added)
+++ db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTIHelper.java Tue Oct 23 13:54:05 2007
@@ -0,0 +1,250 @@
+/*
+
+Derby - Class org.apache.derbyDemo.vtis.core.VTIHelper
+
+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.derbyDemo.vtis.core;
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.math.BigDecimal;
+import java.sql.*;
+
+/**
+ * <p>
+ * VTI helper methods.
+ * </p>
+ *
+  */
+public  abstract  class   VTIHelper
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private static  final   boolean DEBUG = true;
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTORS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // PUBLIC BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Unregister a VTI.
+     * </p>
+     */
+    public  static  void unregisterVTI
+        (
+         Method         method
+         )
+        throws SQLException
+    {
+        String              methodName = method.getName();
+        String              sqlName = doubleQuote( methodName );
+
+        dropObject( "function", sqlName, false );
+    }
+
+    /**
+     * <p>
+     * Register a VTI.
+     * </p>
+     */
+    public  static  void registerVTI
+        (
+         Method         method,
+         String[]       columnNames,
+         String[]       columnTypes,
+         boolean        readsSqlData
+         )
+        throws Exception
+    {
+        String              methodName = method.getName();
+        String              sqlName = doubleQuote( methodName );
+        Class               methodClass = method.getDeclaringClass();
+        Class[]             parameterTypes = method.getParameterTypes();
+        int                 parameterCount = parameterTypes.length;
+        int                 columnCount = columnNames.length;
+        StringBuilder       buffer = new StringBuilder();
+
+        buffer.append( "create function " );
+        buffer.append( sqlName );
+        buffer.append( "\n( " );
+        for ( int i = 0; i < parameterCount; i++ )
+        {
+            if ( i > 0 ) { buffer.append( ", " ); }
+            
+            String      parameterType = mapType( parameterTypes[ i ] );
+
+            buffer.append( "arg" ); buffer.append( i );
+            buffer.append( " " ); buffer.append( parameterType );
+        }
+        buffer.append( " )\n" );
+
+        buffer.append( "returns table\n" );
+        buffer.append( "( " );
+        for ( int i = 0; i < columnCount; i++ )
+        {
+            if ( i > 0 ) { buffer.append( ", " ); }
+
+            buffer.append( "\"" + columnNames[ i ] + "\"" );
+            buffer.append( " " ); buffer.append( columnTypes[ i ] );
+        }
+        buffer.append( " )\n" );
+        
+        buffer.append( "language java\n" );
+        buffer.append( "parameter style DERBY_JDBC_RESULT_SET\n" );
+        if ( readsSqlData ) { buffer.append( "reads sql data\n" ); }
+        else { buffer.append( "no sql\n" ); }
+        
+        buffer.append( "external name " );
+        buffer.append( "'" );
+        buffer.append( methodClass.getName() ); buffer.append( "." ); buffer.append( methodName );
+        buffer.append( "'\n" );
+        
+        executeDDL( buffer.toString() );
+    }
+
+    /**
+     * <p>
+     * Execute a DDL statement to drop an object if it exists. Swallow exceptions.
+     * </p>
+     */
+    public  static  void    dropObject( String objectType, String objectName, boolean objectIfMissing )
+        throws SQLException
+    {
+        String              dropDDL = "drop " + objectType + " " + objectName;
+        Connection          conn = getLocalConnection();
+
+        // Drop the object if it does exist. Swallow exception if it doesn't.
+        print( dropDDL );
+        try {
+            PreparedStatement   dropStatement = conn.prepareStatement( dropDDL );
+            
+            dropStatement.execute();
+            dropStatement.close();
+        } catch (SQLException s)
+        {
+            if ( objectIfMissing ) { throw s; }
+        }
+    }
+    
+    /**
+     * <p>
+     * Execute a DDL statement
+     * </p>
+     */
+    public  static  void    executeDDL( String ddl )
+        throws SQLException
+    {
+        Connection                  conn = getLocalConnection();
+
+        // now register the function
+        print( ddl );
+        try {
+            PreparedStatement   createStatement = conn.prepareStatement( ddl );
+            
+            createStatement.execute();
+            createStatement.close();
+        }
+        catch (SQLException t)
+        {
+            SQLException    s = new SQLException( "Could not execute DDL:\n" + ddl );
+
+            s.setNextException( t );
+
+            throw s;
+        }
+    }
+    
+    /**
+     * <p>
+     * Double-quote a name.
+     * </p>
+     *
+     */
+    public  static  String doubleQuote( String name )
+    { return '\"' + name + '\"'; }
+
+    /**
+     * <p>
+     * Debug helper method to print a diagnostic.
+     * </p>
+     */
+    public  static  void    print( String text )
+    {
+        if ( DEBUG ) { System.out.println( text ); }
+    }
+
+    /**
+     * <p>
+     * Get the connection to the local database.
+     * </p>
+     */
+    public  static  Connection    getLocalConnection()
+        throws SQLException
+    { return DriverManager.getConnection("jdbc:default:connection"); }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // MINIONS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Map a Java type to a SQL type.
+     * </p>
+     */
+    private  static  String  mapType( Class javaType )
+        throws Exception
+    {
+        if ( javaType == Long.class ) { return "bigint"; }
+        else if ( javaType == Blob.class ) { return "blob"; }
+        else if ( javaType == String.class ) { return "varchar( 32672 )"; }
+        else if ( javaType == Clob.class ) { return "clob"; }
+        else if ( javaType == BigDecimal.class ) { return "decimal"; }
+        else if ( javaType == Double.class ) { return "double"; }
+        else if ( javaType == Float.class ) { return "float"; }
+        else if ( javaType == Integer.class ) { return "integer"; }
+        else if ( javaType == byte[].class ) { return "long varchar for bit data"; }
+        else if ( javaType == Short.class ) { return "smallint"; }
+        else if ( javaType == Timestamp.class ) { return "timestamp"; }
+        else { throw new Exception( "Unsupported type of argument to Table Function: " + javaType.getName() ); }
+    }
+    
+
+}
+

Propchange: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTIHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTITemplate.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTITemplate.java?rev=587652&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTITemplate.java (added)
+++ db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTITemplate.java Tue Oct 23 13:54:05 2007
@@ -0,0 +1,1412 @@
+/*
+
+   Derby - Class org.apache.derbyDemo.vtis.core.VTITemplate
+
+   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.derbyDemo.vtis.core;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.math.BigDecimal;
+
+import java.net.URL;
+import java.util.Calendar;
+import java.sql.Ref;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Array;
+
+/**
+	An abstract implementation of ResultSet (JDK1.1/JDBC 1.2) that is useful
+	when writing a read-only VTI (virtual table interface) or for
+	the ResultSet returned by executeQuery in read-write VTI classes.
+	
+	This class implements most of the methods of the JDBC 1.2 interface java.sql.ResultSet,
+	each one throwing a  SQLException with the name of the method. 
+	A concrete subclass can then just implement the methods not implemented here 
+	and override any methods it needs to implement for correct functionality.
+	<P>
+	The methods not implemented here are
+	<UL>
+	<LI>next()
+	<LI>close()
+	<LI>getMetaData()
+	</UL>
+	<P>
+
+	For virtual tables the database engine only calls methods defined
+	in the JDBC 1.2 definition of java.sql.ResultSet.
+	<BR>
+	Classes that implement a JDBC 2.0 conformant java.sql.ResultSet can be used
+	as virtual tables.
+ */
+public abstract class VTITemplate implements ResultSet {
+
+    //
+    // java.sql.ResultSet calls, passed through to our result set.
+    //
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public boolean wasNull() throws SQLException {
+        throw new SQLException("wasNull");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public String getString(int columnIndex) throws SQLException {
+        throw new SQLException("getString");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public boolean getBoolean(int columnIndex) throws SQLException {
+        throw new SQLException("getBoolean");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public byte getByte(int columnIndex) throws SQLException {
+        throw new SQLException("getByte");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public short getShort(int columnIndex) throws SQLException {
+        throw new SQLException("getShort");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public int getInt(int columnIndex) throws SQLException {
+        throw new SQLException("getInt");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public long getLong(int columnIndex) throws SQLException {
+        throw new SQLException("getLong");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+   public float getFloat(int columnIndex) throws SQLException {
+        throw new SQLException("getFloat");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public double getDouble(int columnIndex) throws SQLException {
+        throw new SQLException("getDouble");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+        throw new SQLException("getBigDecimal");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public byte[] getBytes(int columnIndex) throws SQLException {
+        throw new SQLException("getBytes");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.sql.Date getDate(int columnIndex) throws SQLException {
+        throw new SQLException("getDate");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.sql.Time getTime(int columnIndex) throws SQLException {
+        throw new SQLException("getTime");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.sql.Timestamp getTimestamp(int columnIndex) throws SQLException {
+        throw new SQLException("getTimestamp");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.io.InputStream getAsciiStream(int columnIndex) throws SQLException {
+        throw new SQLException("getAsciiStream");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException {
+        throw new SQLException("getUnicodeStream");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.io.InputStream getBinaryStream(int columnIndex)
+        throws SQLException {
+        throw new SQLException("getBinaryStream");
+            }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public String getString(String columnName) throws SQLException {
+        return getString(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public boolean getBoolean(String columnName) throws SQLException {
+        return getBoolean(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public byte getByte(String columnName) throws SQLException {
+        return getByte(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public short getShort(String columnName) throws SQLException {
+        return getShort(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public int getInt(String columnName) throws SQLException {
+        return getInt(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public long getLong(String columnName) throws SQLException {
+        return getLong(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public float getFloat(String columnName) throws SQLException {
+        return getFloat(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public double getDouble(String columnName) throws SQLException {
+        return getDouble(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
+        return getBigDecimal(findColumn(columnName), scale);
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public byte[] getBytes(String columnName) throws SQLException {
+        return getBytes(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.sql.Date getDate(String columnName) throws SQLException {
+        return getDate(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.sql.Time getTime(String columnName) throws SQLException {
+        return getTime(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.sql.Timestamp getTimestamp(String columnName) throws SQLException {
+        return getTimestamp(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.io.InputStream getAsciiStream(String columnName) throws SQLException {
+        throw new SQLException("getAsciiStream");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
+        throw new SQLException("getUnicodeStream");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public java.io.InputStream getBinaryStream(String columnName)
+        throws SQLException {
+        throw new SQLException("getBinaryStream");
+    }
+
+  /**
+ 	* @exception	SQLException if there is an error
+	*/
+  public SQLWarning getWarnings() throws SQLException {
+    return null;
+  }
+
+  /**
+ 	* @exception	SQLException if there is an error
+	*/
+  public void clearWarnings() throws SQLException {
+  }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public String getCursorName() throws SQLException {
+        throw new SQLException("getCursorName");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public Object getObject(int columnIndex) throws SQLException {
+        throw new SQLException("getObject");
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public Object getObject(String columnName) throws SQLException {
+        return getObject(findColumn(columnName));
+    }
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+    public int findColumn(String columnName) throws SQLException {
+        throw new SQLException("findColumn");
+    }
+
+	/*
+	** JDBC 2.0 methods
+	*/
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public java.io.Reader getCharacterStream(int columnIndex)
+					throws SQLException {
+		throw new SQLException("getCharacterStream");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public java.io.Reader getCharacterStream(String columnName)
+					throws SQLException {
+		throw new SQLException("getCharacterStream");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public BigDecimal getBigDecimal(int columnIndex)
+					throws SQLException {
+		throw new SQLException("getBigDecimal");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public BigDecimal getBigDecimal(String columnName)
+					throws SQLException {
+		return getBigDecimal(findColumn(columnName));
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean isBeforeFirst()
+					throws SQLException {
+		throw new SQLException("isBeforeFirst");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean isAfterLast()
+					throws SQLException {
+		throw new SQLException("isAfterLast");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean isFirst()
+					throws SQLException {
+		throw new SQLException("isFirst");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean isLast()
+					throws SQLException {
+		throw new SQLException("isLast");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void beforeFirst()
+					throws SQLException {
+		throw new SQLException("beforeFirst");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void afterLast()
+					throws SQLException {
+		throw new SQLException("afterLast");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean first()
+					throws SQLException {
+		throw new SQLException("first");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean last()
+					throws SQLException {
+		throw new SQLException("last");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public int getRow()
+					throws SQLException {
+		throw new SQLException("getRow");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean absolute(int row)
+					throws SQLException {
+		throw new SQLException("absolute");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean relative(int rows)
+					throws SQLException {
+		throw new SQLException("relative");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean previous()
+					throws SQLException {
+		throw new SQLException("previous");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void setFetchDirection(int direction)
+					throws SQLException {
+		throw new SQLException("setFetchDirection");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public int getFetchDirection()
+					throws SQLException {
+		throw new SQLException("getFetchDirection");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void setFetchSize(int rows)
+					throws SQLException {
+		throw new SQLException("setFetchSize");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public int getFetchSize()
+					throws SQLException {
+		throw new SQLException("getFetchSize");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public int getType()
+					throws SQLException {
+		throw new SQLException("getType");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public int getConcurrency()
+					throws SQLException {
+		throw new SQLException("getConcurrency");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean rowUpdated()
+					throws SQLException {
+		throw new SQLException("rowUpdated");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean rowInserted()
+					throws SQLException {
+		throw new SQLException("rowInserted");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public boolean rowDeleted()
+					throws SQLException {
+		throw new SQLException("rowDeleted");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateNull(int columnIndex)
+					throws SQLException {
+		throw new SQLException("updateNull");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBoolean(int columnIndex, boolean x)
+					throws SQLException {
+		throw new SQLException("updateBoolean");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateByte(int columnIndex, byte x)
+					throws SQLException {
+		throw new SQLException("updateByte");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateShort(int columnIndex, short x)
+					throws SQLException {
+		throw new SQLException("updateShort");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateInt(int columnIndex, int x)
+					throws SQLException {
+		throw new SQLException("updateInt");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateLong(int columnIndex, long x)
+					throws SQLException {
+		throw new SQLException("updateLong");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateFloat(int columnIndex, float x)
+					throws SQLException {
+		throw new SQLException("updateFloat");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateDouble(int columnIndex, double x)
+					throws SQLException {
+		throw new SQLException("updateDouble");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBigDecimal(int columnIndex, BigDecimal x)
+					throws SQLException {
+		throw new SQLException("updateBigDecimal");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateString(int columnIndex, String x)
+					throws SQLException {
+		throw new SQLException("updateString");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBytes(int columnIndex, byte[] x)
+					throws SQLException {
+		throw new SQLException("updateBytes");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateDate(int columnIndex, java.sql.Date x)
+					throws SQLException {
+		throw new SQLException("updateDate");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateTime(int columnIndex, java.sql.Time x)
+					throws SQLException {
+		throw new SQLException("updateTime");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateTimestamp(int columnIndex, java.sql.Timestamp x)
+					throws SQLException {
+		throw new SQLException("updateTimestamp");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateAsciiStream(int columnIndex,
+							java.io.InputStream x,
+							int length)
+					throws SQLException {
+		throw new SQLException("updateAsciiStream");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBinaryStream(int columnIndex,
+							java.io.InputStream x,
+							int length)
+					throws SQLException {
+		throw new SQLException("updateBinaryStream");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateCharacterStream(int columnIndex,
+							java.io.Reader x,
+							int length)
+					throws SQLException {
+		throw new SQLException("updateCharacterStream");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateObject(int columnIndex,
+							Object x,
+							int scale)
+					throws SQLException {
+		throw new SQLException("updateObject");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateObject(int columnIndex, Object x)
+					throws SQLException {
+		throw new SQLException("updateObject");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateNull(String columnName)
+					throws SQLException {
+		throw new SQLException("updateNull");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBoolean(String columnName, boolean x)
+					throws SQLException {
+		throw new SQLException("updateBoolean");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateByte(String columnName, byte x)
+					throws SQLException {
+		throw new SQLException("updateByte");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateShort(String columnName, short x)
+					throws SQLException {
+		throw new SQLException("updateShort");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateInt(String columnName, int x)
+					throws SQLException {
+		throw new SQLException("updateInt");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateLong(String columnName, long x)
+					throws SQLException {
+		throw new SQLException("updateLong");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateFloat(String columnName, float x)
+					throws SQLException {
+		throw new SQLException("updateFloat");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateDouble(String columnName, double x)
+					throws SQLException {
+		throw new SQLException("updateDouble");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBigDecimal(String columnName, BigDecimal x)
+					throws SQLException {
+		throw new SQLException("updateBigDecimal");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateString(String columnName, String x)
+					throws SQLException {
+		throw new SQLException("updateString");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBytes(String columnName, byte[] x)
+					throws SQLException {
+		throw new SQLException("updateBytes");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateDate(String columnName, java.sql.Date x)
+					throws SQLException {
+		throw new SQLException("updateDate");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateTime(String columnName, java.sql.Time x)
+					throws SQLException {
+		throw new SQLException("updateTime");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateTimestamp(String columnName, java.sql.Timestamp x)
+					throws SQLException {
+		throw new SQLException("updateTimestamp");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateAsciiStream(String columnName,
+							java.io.InputStream x,
+							int length)
+					throws SQLException {
+		throw new SQLException("updateAsciiStream");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBinaryStream(String columnName,
+							java.io.InputStream x,
+							int length)
+					throws SQLException {
+		throw new SQLException("updateBinaryStream");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateCharacterStream(String columnName,
+							java.io.Reader x,
+							int length)
+					throws SQLException {
+		throw new SQLException("updateCharacterStream");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateObject(String columnName,
+							Object x,
+							int scale)
+					throws SQLException {
+		throw new SQLException("updateObject");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateObject(String columnName, Object x)
+					throws SQLException {
+		throw new SQLException("updateObject");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void insertRow()
+					throws SQLException {
+		throw new SQLException("insertRow");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateRow()
+					throws SQLException {
+		throw new SQLException("updateRow");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void deleteRow()
+					throws SQLException {
+		throw new SQLException("deleteRow");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void refreshRow()
+					throws SQLException {
+		throw new SQLException("refreshRow");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void cancelRowUpdates()
+					throws SQLException {
+		throw new SQLException("cancelRowUpdates");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void moveToInsertRow()
+					throws SQLException {
+		throw new SQLException("moveToInsertRow");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void moveToCurrentRow()
+					throws SQLException {
+		throw new SQLException("moveToCurrentRow");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Statement getStatement()
+					throws SQLException {
+		throw new SQLException("getStatement");
+	}
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public java.sql.Date getDate(int columnIndex, Calendar cal)
+					throws SQLException {
+		throw new SQLException("getDate");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public java.sql.Date getDate(String columnName, Calendar cal)
+					throws SQLException {
+		throw new SQLException("getDate");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public java.sql.Time getTime(int columnIndex, Calendar cal)
+					throws SQLException {
+		throw new SQLException("getTime");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public java.sql.Time getTime(String columnName, Calendar cal)
+					throws SQLException {
+		throw new SQLException("getTime");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal)
+					throws SQLException {
+		throw new SQLException("getTimestamp");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public java.sql.Timestamp getTimestamp(String columnName, Calendar cal)
+					throws SQLException {
+		throw new SQLException("getTimestamp");
+	}
+	/*
+	** JDBC 3.0 methods
+	*/
+	
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public URL getURL(int columnIndex)
+    throws SQLException
+	{
+		throw new SQLException("getURL");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public URL getURL(String columnName)
+					throws SQLException {
+		throw new SQLException("getURL");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Object getObject(int i, java.util.Map map)
+					throws SQLException {
+		throw new SQLException("getObject");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Ref getRef(int i)
+					throws SQLException {
+		throw new SQLException("getRef");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Blob getBlob(int i)
+					throws SQLException {
+		throw new SQLException("getBlob");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Clob getClob(int i)
+					throws SQLException {
+		throw new SQLException("getClob");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Array getArray(int i)
+					throws SQLException {
+		throw new SQLException("getArray");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Object getObject(String colName, java.util.Map map)
+					throws SQLException {
+		throw new SQLException("getObject");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Ref getRef(String colName)
+					throws SQLException {
+		throw new SQLException("getRef");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Blob getBlob(String colName)
+					throws SQLException {
+		throw new SQLException("getBlob");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Clob getClob(String colName)
+					throws SQLException {
+		throw new SQLException("getClob");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public Array getArray(String colName)
+					throws SQLException {
+		throw new SQLException("getArray");
+	}
+
+
+	// JDBC 3.0 methods - not implemented
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateRef(int columnIndex, Ref x)
+					throws SQLException {
+		throw new SQLException("updateRef");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateRef(String columnName, Ref x)
+					throws SQLException {
+		throw new SQLException("updateRef");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBlob(int columnIndex, Blob x)
+					throws SQLException {
+		throw new SQLException("updateBlob");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateBlob(String columnName, Blob x)
+					throws SQLException {
+		throw new SQLException("updateBlob");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateClob(int columnIndex, Clob x)
+					throws SQLException {
+		throw new SQLException("updateClob");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateClob(String columnName, Clob x)
+					throws SQLException {
+		throw new SQLException("updateClob");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateArray(int columnIndex, Array x)
+					throws SQLException {
+		throw new SQLException("updateArray");
+	}
+
+	/**
+	 * @see java.sql.ResultSet
+	 *
+ 	 * @exception SQLException on unexpected JDBC error
+	 */
+	public void updateArray(String columnName, Array x)
+					throws SQLException {
+		throw new SQLException("updateArray");
+	}
+}

Propchange: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/VTITemplate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/XMLRow.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/XMLRow.java?rev=587652&view=auto
==============================================================================
--- db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/XMLRow.java (added)
+++ db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/XMLRow.java Tue Oct 23 13:54:05 2007
@@ -0,0 +1,60 @@
+/*
+
+Derby - Class org.apache.derbyDemo.vtis.core.XMLRow
+
+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.derbyDemo.vtis.core;
+
+import java.lang.annotation.*;
+
+/**
+ * <p>
+ * This is an Annotation describing how to decompose an XML file into
+ * relational rows.
+ * </p>
+ *
+  */
+@Retention( value=RetentionPolicy.RUNTIME )
+public  @interface  XMLRow
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /** The tag name of Elements which should be mapped to SQL rows */
+    String      rowTag();
+    
+    /** The columns in a row, including the column names and their lengths */
+    String[]   childTags();    
+    
+    /** The types of the columns corresponding to the child tags*/
+    String[]   childTypes();    
+
+    /** The name of the VTI class which produces the rows */
+    String      vtiClassName();
+    
+}

Propchange: db/derby/code/trunk/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/XMLRow.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message