package mit.sql ;

public class Connection
implements sql.Connection
{
	private static final String EXECUTEUPDATE = "executeUpdate" ;
	private static final String CALLPROCEDURE = "callProcedure" ;
	private static final String COLUMN_NAME = "COLUMN_NAME" ;
	private static final String COLUMN_TYPE = "COLUMN_TYPE" ;
	private static final String DATA_TYPE = "DATA_TYPE" ;
	private static final String SEQUENCE = "SEQUENCE" ;

	public sql.Table getProcedures
		( String catalog
		, String schemaPattern
		, String procedureNamePattern
		)
		throws Exception
	{
		return mit.sql.Table.getProcedures
			( this
			, catalog
			, schemaPattern
			, procedureNamePattern
			) ;
	}

	public sql.Table getProcedureColumns
		( String catalog
		, String schemaPattern
		, String procedureName
		, String columnNamePattern
		)
		throws Exception
	{
		return mit.sql.Table.getProcedureColumns
			( this
			, catalog
			, schemaPattern
			, procedureName
			, columnNamePattern
			) ;
	}

	public sql.Table getTables()
		throws Exception
	{
		return mit.sql.Table.getTables
			( this
			) ;
	}

	public sql.Table getTables
		( String catalog
		, String schemaPattern
		, String tableNamePattern
		, String[] tableTypes
		)
		throws Exception
	{
		return mit.sql.Table.getTables
			( this
			, catalog
			, schemaPattern
			, tableNamePattern
			, tableTypes
			) ;
	}

	public sql.Table executeQuery( String sql )
		throws Exception
	{
		return mit.sql.Table.executeQuery
			( this
			, sql
			) ;
	}

	public sql.Table executeQuery
		( String sql
		, Object[] objs
		)
		throws Exception
	{
		return mit.sql.Table.executeQuery
			( this
			, sql
			, objs
			) ;
	}

	public sql.Table executeQuery
		( String sql
		, Object[] objs
		, int[] targetSqlTypes
		)
		throws Exception
	{
		return mit.sql.Table.executeQuery
			( this
			, sql
			, objs
			, targetSqlTypes
			) ;
	}

	public sql.Table executeQuery
		( String sql
		, Object[] objs
		, int[] targetSqlTypes
		, int[] scales
		)
		throws Exception
	{
		return mit.sql.Table.executeQuery
			( this
			, sql
			, objs
			, targetSqlTypes
			, scales
			) ;
	}

	public int executeUpdate( String sql )
		throws Exception
	{
		if( hasClient() )
		{
			return executeUpdateRemotely( sql ) ;
		}
		return executeUpdateLocally( sql ) ;
	}

	private int executeUpdateRemotely( String sql )
		throws Exception
	{
		Class[] argsTypes = new Class[ 1 ] ;
		Object[] args = new Object[ 1 ] ;
		argsTypes[ 0 ] = sql.getClass() ;
		args[ 0 ] = sql ;
		Number num = ( Number ) getClient().invoke( this , EXECUTEUPDATE , argsTypes , args ) ;
		return num.intValue() ;
	}

	public boolean hasClient()
		throws Exception
	{
		return mit.util.RuntimeContext.contains
			( new String( clientstr ) ) ;
	}

	public mit.rmi.Client getClient()
		throws Exception
	{
		if( hasClient() )
		{
			return ( mit.rmi.Client ) mit.util.RuntimeContext.getProperty
					( new String( clientstr ) ) ;
		}
		return null ;
	}

	public int executeUpdateLocally( String sql )
		throws Exception
	{
		java.sql.Statement statement = null ;
		try
		{
			java.sql.Connection conn = getConnection() ;
			statement = conn.createStatement() ;
			int rowCount = statement.executeUpdate( sql ) ;
			statement.close() ; statement = null ;
			return rowCount ;
		}
		catch( Exception ex )
		{
			if( null != statement )
			{
				statement.close() ;
			}
			throw ex ;
		}
	}

	public int executeUpdate( String sql , Object[] objs )
		throws Exception
	{
		if( hasClient() )
		{
			return executeUpdateRemotely( sql , objs ) ;
		}
		return executeUpdateLocally( sql , objs ) ;
	}

	private int executeUpdateRemotely( String sql , Object[] objs )
		throws Exception
	{
		Class[] argsTypes = new Class[ 2 ] ;
		Object[] args = new Object[ 2 ] ;
		argsTypes[ 0 ] = sql.getClass() ;
		argsTypes[ 1 ] = objs.getClass() ;
		args[ 0 ] = sql ;
		args[ 1 ] = objs ;
		Number num = ( Number ) getClient().invoke( this , EXECUTEUPDATE , argsTypes , args ) ;
		return num.intValue() ;
	}

	public int executeUpdateLocally( String sql , Object[] objs )
		throws Exception
	{
		java.sql.PreparedStatement statement = null ;
		try
		{
			java.sql.Connection conn = getConnection() ;
			statement = conn.prepareStatement( sql ) ;
			for( int i = 0 ; objs.length != i ; i ++ )
			{
				statement.setObject( i + 1 , objs[ i ] ) ;
			}
			int rowCount = statement.executeUpdate() ;
			statement.close() ; statement = null ;
			return rowCount ;
		}
		catch( Exception ex )
		{
			if( null != statement )
			{
				statement.close() ;
			}
			throw ex ;
		}
	}

	public int executeUpdate( String sql , Object[] objs , int[] targetSqlTypes )
		throws Exception
	{
		if( hasClient() )
		{
			return executeUpdateRemotely( sql , objs , targetSqlTypes ) ;
		}
		return executeUpdateLocally( sql , objs  , targetSqlTypes ) ;
	}

	private int executeUpdateRemotely
		( String sql
		, Object[] objs
		, int[] targetSqlTypes
		)
		throws Exception
	{
		Class[] argsTypes = new Class[ 3 ] ;
		Object[] args = new Object[ 3 ] ;
		argsTypes[ 0 ] = sql.getClass() ;
		argsTypes[ 1 ] = objs.getClass() ;
		argsTypes[ 2 ] = targetSqlTypes.getClass() ;
		args[ 0 ] = sql ;
		args[ 1 ] = objs ;
		args[ 2 ] = targetSqlTypes ;
		Number num = ( Number ) getClient().invoke( this , EXECUTEUPDATE , argsTypes , args ) ;
		return num.intValue() ;
	}

	public int executeUpdateLocally( String sql , Object[] objs , int[] targetSqlTypes )
		throws Exception
	{
		java.sql.PreparedStatement statement = null ;
		try
		{
			java.sql.Connection conn = getConnection() ;
			statement = conn.prepareStatement( sql ) ;
			for( int i = 0 ; objs.length != i ; i ++ )
			{
				statement.setObject( i + 1 , objs[ i ] , targetSqlTypes[ i ] ) ;
			}
			int rowCount = statement.executeUpdate() ;
			statement.close() ; statement = null ;
			return rowCount ;
		}
		catch( Exception ex )
		{
			if( null != statement )
			{
				statement.close() ;
			}
			throw ex ;
		}
	}

	public int executeUpdate( String sql , Object[] objs , int[] targetSqlTypes , int[] scales )
		throws Exception
	{
		if( hasClient() )
		{
			return executeUpdateRemotely( sql , objs , targetSqlTypes , scales ) ;
		}
		return executeUpdateLocally( sql , objs  , targetSqlTypes , scales ) ;
	}

	private int executeUpdateRemotely
		( String sql
		, Object[] objs
		, int[] targetSqlTypes
		, int[] scales
		)
		throws Exception
	{
		Class[] argsTypes = new Class[ 4 ] ;
		Object[] args = new Object[ 4 ] ;
		argsTypes[ 0 ] = sql.getClass() ;
		argsTypes[ 1 ] = objs.getClass() ;
		argsTypes[ 2 ] = targetSqlTypes.getClass() ;
		argsTypes[ 3 ] = scales.getClass() ;
		args[ 0 ] = sql ;
		args[ 1 ] = objs ;
		args[ 2 ] = targetSqlTypes ;
		args[ 3 ] = scales ;
		Number num = ( Number ) getClient().invoke( this , EXECUTEUPDATE , argsTypes , args ) ;
		return num.intValue() ;
	}

	public int executeUpdateLocally( String sql , Object[] objs , int[] targetSqlTypes , int [] scales )
		throws Exception
	{
		java.sql.PreparedStatement statement = null ;
		try
		{
			java.sql.Connection conn = getConnection() ;
			statement = conn.prepareStatement( sql ) ;
			for( int i = 0 ; objs.length != i ; i ++ )
			{
				statement.setObject( i + 1 , objs[ i ] , targetSqlTypes[ i ] , scales[ i ] ) ;
			}
			int rowCount = statement.executeUpdate() ;
			statement.close() ; statement = null ;
			return rowCount ;
		}
		catch( Exception ex )
		{
			if( null != statement )
			{
				statement.close() ;
			}
			throw ex ;
		}
	}

	public void commit()
		throws Exception
	{
		try
		{
			if( ! getAutoCommit().booleanValue() )
			{
				getConnection().commit() ;
			}
		}
		catch( Exception ex )
		{
			resetConnection() ;
			throw ex ;
		}
	}

	public void rollback()
		throws Exception
	{
		try
		{
			if( ! getAutoCommit().booleanValue() )
			{
				getConnection().rollback() ;
			}
		}
		catch( Exception ex )
		{
			resetConnection() ;
			throw ex ;
		}
	}

	public sql.Table callProcedure
		( String procedureName
		, Object[] args
		, int[] columnTypes
		, int[] dataTypes
		)
		throws Exception
	{
		return callProcedure
			( ( String ) null
			, ( String ) null
			, procedureName
			, ( String ) null
			, args
			, columnTypes
			, dataTypes
			) ;
	}

	public sql.Table callProcedure
		( String catalog
		, String schemaPattern
		, String procedureName
		, String columnNamePattern
		, Object[] args
		, int[] columnTypes
		, int[] dataTypes
		)
		throws Exception
	{
		if( hasClient() )
		{
			return callProcedureRemotely
				( catalog
				, schemaPattern
				, procedureName
				, columnNamePattern
				, args
				, columnTypes
				, dataTypes
				) ;
		}
		return callProcedureLocally
			( catalog
			, schemaPattern
			, procedureName
			, columnNamePattern
			, args
			, columnTypes
			, dataTypes
			) ;
	}

	private sql.Table callProcedureRemotely
		( String catalog
		, String schemaPattern
		, String procedureName
		, String columnNamePattern
		, Object[] arguments
		, int[] columnTypes
		, int[] dataTypes
		)
		throws Exception
	{
		Class[] argsTypes = new Class[ 7 ] ;
		Object[] args = new Object[ 7 ] ;
		argsTypes[ 0 ]
			= ( null != catalog ) ? catalog.getClass() : null ;
		argsTypes[ 1 ]
			= ( null != schemaPattern ) ? schemaPattern.getClass() : null ;
		argsTypes[ 2 ]
			= ( null != procedureName ) ? procedureName.getClass() : null ;
		argsTypes[ 3 ]
			= ( null != columnNamePattern ) ? columnNamePattern.getClass() : null ;
		argsTypes[ 4 ]
			= ( null != arguments ) ? arguments.getClass() : null ;
		argsTypes[ 5 ]
			= ( null != columnTypes ) ? columnTypes.getClass() : null ;
		argsTypes[ 6 ]
			= ( null != dataTypes ) ? dataTypes.getClass() : null ;
		args[ 0 ] = catalog ;
		args[ 1 ] = schemaPattern ;
		args[ 2 ] = procedureName ;
		args[ 3 ] = columnNamePattern ;
		args[ 4 ] = arguments ;
		args[ 5 ] = columnTypes ;
		args[ 6 ] = dataTypes ;
		return ( sql.Table ) getClient().invoke( this , CALLPROCEDURE , argsTypes , args ) ;
	}

	public sql.Table callProcedureLocally
		( String catalog
		, String schemaPattern
		, String procedureName
		, String columnNamePattern
		, Object[] args
		, int[] columnTypes
		, int[] dataTypes
		)
		throws Exception
	{
		java.sql.CallableStatement stmt = null ;
		try
		{
			if
			(  ( null != procedureName )
			&& ( null != args )
			&& ( null != columnTypes )
			&& ( null != dataTypes )
			)
			{
				stmt
					= setStatement
						( catalog
						, schemaPattern
						, procedureName
						, columnNamePattern
						, args
						, columnTypes
						, dataTypes
						) ;

				stmt.execute() ;
				sql.Table table = createTable( stmt , columnTypes , dataTypes ) ;
				stmt.close() ;
				return table ;
			}
			throw new sql.ConnectionException
				( sql.ConnectionException.INVALIDARGUMENTS ) ;
		}
		catch( Exception ex )
		{
			if( null != stmt )
			{
				stmt.close() ;
			}
			resetConnection() ;
			throw ex ;
		}
	}

	private java.sql.CallableStatement setStatement
		( String catalog
		, String schemaPattern
		, String procedureName
		, String columnNamePattern
		, Object[] args
		, int[] columnTypes
		, int[] dataTypes
		)
		throws Exception
	{
		String params = "" ;
		java.sql.CallableStatement stmt = null ;
		for( int i = 0 ; args.length != i ; i ++ )
		{
			Object arg = args[ i ] ;
			int columnType = columnTypes[ i ] ;
			int datatype = dataTypes[ i ] ;
			int sequence = i + 1 ;
			if( null == arg )
			{
				arg = "" ;
			}
			switch( columnType )
			{
			case java.sql.DatabaseMetaData.procedureColumnIn:
			default:
				if( args.length != i )
				{
					if( datatype == java.sql.Types.OTHER )
					{
						stmt.setObject( sequence , arg , java.sql.Types.FLOAT , 0 ) ;
					}
					else
					{
						stmt.setObject( sequence , arg , datatype ) ;
					}
				}
				break ;
			case java.sql.DatabaseMetaData.procedureColumnInOut:
				if( datatype == java.sql.Types.OTHER )
				{
					stmt.setObject( sequence , arg , java.sql.Types.FLOAT , 0 ) ;
					stmt.registerOutParameter( sequence , java.sql.Types.FLOAT , 0 ) ;
				}
				else
				{
					stmt.setObject( sequence , arg , datatype ) ;
					stmt.registerOutParameter( sequence , datatype ) ;
				}
				break ;
			case java.sql.DatabaseMetaData.procedureColumnOut:
				if( datatype == java.sql.Types.OTHER )
				{
					stmt.registerOutParameter( sequence , java.sql.Types.FLOAT , 0 ) ;
				}
				else
				{
					stmt.registerOutParameter( sequence , datatype ) ;
				}
				break ;
			case java.sql.DatabaseMetaData.procedureColumnReturn:
				break ;
			case java.sql.DatabaseMetaData.procedureColumnResult:
				break ;
			case java.sql.DatabaseMetaData.procedureColumnUnknown:
				break ;
			}
			if( 0 != i ) { params += ", " ; }
			params += "?" ;
		}
		String sql = "{call " + procedureName + "(" + params + ")}" ;
		stmt = getConnection().prepareCall( sql ) ;
		return stmt ;
	}

	private sql.Table createTable
		( java.sql.CallableStatement stmt
		, int[] columnTypes
		, int[] dataTypes
		)
		throws Exception
	{
		java.util.Vector outColumnsV = new java.util.Vector() ;
		java.util.Vector outColumnsMetaDataV = new java.util.Vector() ;
		for( int i = 0 ; columnTypes.length != i ; i ++ )
		{

			switch( columnTypes[ i ] )
			{
			case java.sql.DatabaseMetaData.procedureColumnInOut:
			case java.sql.DatabaseMetaData.procedureColumnOut:
				mit.sql.ColumnMetaData colMetaData
					= new mit.sql.ColumnMetaData( i + 1 , null ) ;
				colMetaData.columnType = dataTypes[ i ] ;
				outColumnsV.addElement( stmt.getObject( i + 1 ) ) ;
				outColumnsMetaDataV.addElement( colMetaData ) ;
				break ;
			default:
				if( null != stmt )
				{
					stmt.close() ;
					stmt = null ;
				}
				resetConnection() ;
				throw new sql.ConnectionException( "" ) ;
			}
		}
		sql.ColumnMetaData[] columnsMetaData = new sql.ColumnMetaData[ outColumnsMetaDataV.size() ] ;
		Object[] columns = new Object[ outColumnsV.size() ] ;
		for( int i = 0 ; columns.length != i ; i ++ )
		{
			columnsMetaData[ i ]
				= ( sql.ColumnMetaData ) outColumnsMetaDataV.elementAt( i ) ;
			columns[ i ] = outColumnsV.elementAt( i ) ;
		}
		Object[] onerow = new Object[ 1 ] ;
		onerow[ 0 ] = ( Object ) columns ;
		sql.RowsMetaData rowsMetaData = new mit.sql.RowsMetaData( columnsMetaData ) ;
		sql.Rows rows2 = new mit.sql.Rows( rowsMetaData , onerow ) ;
		sql.Table table = new mit.sql.Table( this , rows2 ) ;
		return table ;
	}

	protected static String connstr = ".Connection" ;
	protected static String clientstr = "mit.rmi.Client" ;
	protected static int ROWS_IN_BLOCK = 1000 ;

	private static final String EMPTYSTRING = "" ;
	private static final Integer DEFAULTCONNECTION = new Integer( 0 ) ;

	private String database = EMPTYSTRING ;
	public String getDatabase() { return this.database ; }
	private void setDatabase( String database )
	{
		resetCacheId() ;
		this.database = EMPTYSTRING ;
		if( null != database )
		{
			this.database = database ;
		}
	}

	private static final String DEFAULTDATABASEURLPREFIX = "jdbc:oracle:oci8:@" ;
	private String databaseURL = EMPTYSTRING ;
	public String getDatabaseURL() { return this.databaseURL ; }
	private void setDatabaseURL( String databaseURL )
	{
		resetCacheId() ;
		this.databaseURL = EMPTYSTRING ;
		if( null != databaseURL )
		{
			this.databaseURL = databaseURL ;
		}
	}

	private static final String DEFAULTDRIVERNAME = "oracle.jdbc.driver.OracleDriver" ;
	private String driverName = DEFAULTDRIVERNAME ;
	public String getDriverName() { return this.driverName ; }
	public void setDriverName( String driverName ) { this.driverName = driverName ; }

	private String username = EMPTYSTRING ;
	public String getUsername() { return this.username ; }
	private void setUsername( String username )
	{
		resetCacheId() ;
		this.username = EMPTYSTRING ;
		if( null != username )
		{
			this.username = username ;
		}
	}

	private String password = EMPTYSTRING ;
	private String getPassword() { return this.password ; }
	private void setPassword( String password )
	{
		resetCacheId() ;
		this.password = EMPTYSTRING ;
		if( null != password )
		{
			this.password = password ;
		}
	}

	private Boolean autoCommit = new Boolean( true ) ;
	public Boolean getAutoCommit() { return this.autoCommit ; }
	public void setAutoCommit( Boolean autoCommit )
	{
		try
		{
			if( ! this.autoCommit.equals( autoCommit ) )
			{
				resetConnection() ;
				this.autoCommit = autoCommit ;
			}
		}
		catch( Exception ex )
		{
			ex.printStackTrace() ;
		}
	}

	private Connection()
	{
		super() ;
	}

	public static sql.Connection create
		( String databaseURL
		, String driverName
		, String username
		, String password
		, Object id
		)
		throws Exception
	{
		String exStr = sql.ConnectionException.INVALIDUSERNAME ;
		if( null != username )
		{
			if( null != password )
			{
				if( null != databaseURL )
				{
					if( null != driverName )
					{
						mit.sql.Connection db = ( mit.sql.Connection ) new mit.sql.Connection() ;
						db.setDatabase( null ) ;
						db.setDatabaseURL( databaseURL ) ;
						db.setDriverName( driverName ) ;
						db.setUsername( username ) ;
						db.setPassword( password ) ;
						db.setId( id ) ;
						return db ;
					}
					else
					{
						exStr = sql.ConnectionException.INVALIDDRIVERNAME ;
					}
				}
				else
				{
					exStr = sql.ConnectionException.INVALIDDATABASEURL ;
				}
			}
			else
			{
				exStr = sql.ConnectionException.INVALIDPASSWORD ;
			}
		}
		throw new sql.ConnectionException( exStr ) ;
	}

	public static sql.Connection create
		( String database
		, String username
		, String password
		, Object id
		)
		throws Exception
	{
		String exStr = sql.ConnectionException.INVALIDDATABASE ;
		if( null != database )
		{
			if( null != username )
			{
				if( null != password )
				{
					mit.sql.Connection db = ( mit.sql.Connection ) new mit.sql.Connection() ;
					db.setDatabase( database ) ;
					db.setDatabaseURL( null ) ;
					db.setDriverName( DEFAULTDRIVERNAME ) ;
					db.setUsername( username ) ;
					db.setPassword( password ) ;
					db.setId( id ) ;
					return db ;
				}
				else
				{
					exStr = sql.ConnectionException.INVALIDPASSWORD ;
				}
			}
			else
			{
				exStr = sql.ConnectionException.INVALIDUSERNAME ;
			}
		}
		throw new sql.ConnectionException( exStr ) ;
	}

	private Object id = DEFAULTCONNECTION ;
	public Object getId() { return this.id ; }
	private void setId( Object id )
	{
		this.id = DEFAULTCONNECTION ;
		if( null != id )
		{
			this.id = id ;
		}
	}

	public boolean equals( sql.Connection db )
	{
		return
		(
			( this == db )
			||
			(  ( null != db )
			&& ( db instanceof mit.sql.Connection )
			&& ( getCacheId().equals( ( ( mit.sql.Connection ) db ).getCacheId() ) )
			)
		) ;
	}

	private Object cacheId = null ;
	private Object getCacheId()
	{
		if( null == this.cacheId )
		{
			int hashDatabase = getDatabase().hashCode() ;
			int hashDatabaseURL = getDatabaseURL().hashCode() ;
			int hashUsername = getUsername().hashCode() ;
			int hashPassword = getPassword().hashCode() ;
			String cacheIdStr
				= Integer.toString( hashDatabase )
				+ Integer.toString( hashDatabaseURL )
				+ Integer.toString( hashUsername )
				+ Integer.toString( hashPassword )
				+ getId().toString()
				;
			this.cacheId = Integer.toString( cacheIdStr.hashCode() ) ;
		}
		return this.cacheId ;
	}
	private void resetCacheId() { this.cacheId = null ; }

	public void connect()
		throws Exception
	{
		getConnection() ;
	}

	public void disconnect()
		throws Exception
	{
		resetConnection() ;
	}

	protected java.sql.Connection getConnection()
	{
		try
		{
			java.sql.Connection conn
				= ( java.sql.Connection ) mit.util.RuntimeContext.getProperty
					( new String( getCacheId() + connstr ) ) ;
			if( null == conn )
			{
				String dbURL = DEFAULTDATABASEURLPREFIX + getDatabase() ;
				if( ! EMPTYSTRING.equals( getDatabaseURL() ) )
				{
					dbURL = getDatabaseURL() ;
				}
				mit.sql.Connect connect
					= new mit.sql.Connect
						( getDriverName()
						, dbURL
						, getUsername()
						, getPassword()
						) ;
				conn = connect.getConnection() ;
				conn.setAutoCommit( getAutoCommit().booleanValue() ) ;
				mit.util.RuntimeContext.setProperty
					( new String( getCacheId() + connstr ) , conn ) ;
			}
			return conn ;
		}
		catch( Exception ex )
		{
		}
		return null ;
	}

	protected void resetConnection()
		throws Exception
	{
		String connectionTag = getCacheId() + connstr ;
		java.sql.Connection conn
			= ( java.sql.Connection ) mit.util.RuntimeContext.getProperty
				( new String( connectionTag ) ) ;
		if( null != conn )
		{
			conn.close() ;
			mit.util.RuntimeContext.setProperty( connectionTag , null ) ;
		}
	}

	private String findDataTypeName( int datatype )
	{
		for( int i = 0 ; types.length != i ; i ++ )
		{
			if( types[ i ] == datatype )
			{
				return typeNames[ i ] ;
			}
		}
		return null ;
	}

	private static int[] types =
	{	java.sql.Types.ARRAY
	,	java.sql.Types.BIGINT
	,	java.sql.Types.BINARY
	,	java.sql.Types.BIT
	,	java.sql.Types.BLOB
	,	java.sql.Types.CHAR
	,	java.sql.Types.CLOB
	,	java.sql.Types.DATE
	,	java.sql.Types.DECIMAL
	,	java.sql.Types.DISTINCT
	,	java.sql.Types.DOUBLE
	,	java.sql.Types.FLOAT
	,	java.sql.Types.INTEGER
	,	java.sql.Types.JAVA_OBJECT
	,	java.sql.Types.LONGVARBINARY
	,	java.sql.Types.LONGVARCHAR
	,	java.sql.Types.NULL
	,	java.sql.Types.NUMERIC
	,	java.sql.Types.OTHER
	,	java.sql.Types.REAL
	,	java.sql.Types.REF
	,	java.sql.Types.SMALLINT
	,	java.sql.Types.STRUCT
	,	java.sql.Types.TIME
	,	java.sql.Types.TIMESTAMP
	,	java.sql.Types.TINYINT
	,	java.sql.Types.VARBINARY
	,	java.sql.Types.VARCHAR
	} ;

  	private static String[] typeNames =
  	{	"java.sql.Types.ARRAY"
	,	"java.sql.Types.BIGINT"
	,	"java.sql.Types.BINARY"
	,	"java.sql.Types.BIT"
	,	"java.sql.Types.BLOB"
	,	"java.sql.Types.CHAR"
	,	"java.sql.Types.CLOB"
	,	"java.sql.Types.DATE"
	,	"java.sql.Types.DECIMAL"
	,	"java.sql.Types.DISTINCT"
	,	"java.sql.Types.DOUBLE"
	,	"java.sql.Types.FLOAT"
	,	"java.sql.Types.INTEGER"
	,	"java.sql.Types.JAVA_OBJECT"
	,	"java.sql.Types.LONGVARBINARY"
	,	"java.sql.Types.LONGVARCHAR"
	,	"java.sql.Types.NULL"
	,	"java.sql.Types.NUMERIC"
	,	"java.sql.Types.OTHER"
	,	"java.sql.Types.REAL"
	,	"java.sql.Types.REF"
	,	"java.sql.Types.SMALLINT"
	,	"java.sql.Types.STRUCT"
	,	"java.sql.Types.TIME"
	,	"java.sql.Types.TIMESTAMP"
	,	"java.sql.Types.TINYINT"
	,	"java.sql.Types.VARBINARY"
	,	"java.sql.Types.VARCHAR"
	} ;

}