Index: .gitignore
===================================================================
--- .gitignore (revision 2552)
+++ .gitignore (working copy)
@@ -49,6 +49,7 @@
/web/modeshape-web-jcr-webdav-war/target/
/utils/modeshape-jdbc/target/
+/utils/modeshape-jdbc-local/target/
/utils/modeshape-jpa-ddl-gen/target/
/deploy/jbossas/target/
Index: deploy/jbossas/assembly/kit.xml
===================================================================
--- deploy/jbossas/assembly/kit.xml (revision 2552)
+++ deploy/jbossas/assembly/kit.xml (working copy)
@@ -77,7 +77,7 @@
+ * This method pre-processes the supplied SQL-compatible query and returns the corresponding JCR-SQL2.
+ *
+ * This driver maps the repository name as the JDBC catalog name. Therefore, this method returns 'Repository' for the catalog
+ * term.
+ *
+ * This driver maps the repository name as the JDBC catalog name. Therefore, this method returns a result set containing only
+ * the repository's name.
+ * > records = new ArrayList
>(1);
+
+ List
> records = new ArrayList
>();
+
+ try {
+
+ List
+ * Note that any use of URL encoding ('%' followed by a two-digit hexadecimal value) will be decoded before being used. + *
+ * Note that any use of URL encoding ('%' followed by a two-digit hexadecimal value) will be decoded before being used. + */ + +public class LocalJcrDriver implements java.sql.Driver { + protected static Logger logger = Logger.getLogger("org.modeshape.jdbc"); //$NON-NLS-1$ + + public static final String WORKSPACE_PROPERTY_NAME = "workspace"; + public static final String REPOSITORY_PROPERTY_NAME = "repositoryName"; + public static final String USERNAME_PROPERTY_NAME = "user"; + public static final String PASSWORD_PROPERTY_NAME = "password"; + + protected static final Set+ * Note that if the supplied properties and URL contain properties with the same name, the value from the supplied Properties + * object will take precedence. + *
+ * + * @see java.sql.Driver#connect(java.lang.String, java.util.Properties) + */ + @Override + public Connection connect( String url, + Properties info ) throws SQLException { + + return delegateFactory.createRepositoryDelegate(url, info, this.contextFactory).createConnection(getDriverInfo()); + } + + /** + * {@inheritDoc} + * + * @see java.sql.Driver#getMajorVersion() + */ + @Override + public int getMajorVersion() { + return getDriverInfo().getMajorVersion(); + } + + /** + * {@inheritDoc} + * + * @see java.sql.Driver#getMinorVersion() + */ + @Override + public int getMinorVersion() { + return getDriverInfo().getMinorVersion(); + } + + public String getVendorName() { + return getDriverInfo().getVendorName(); + } + + public String getVendorUrl() { + return getDriverInfo().getVendorUrl(); + } + + public String getVersion() { + return getDriverInfo().getVersion(); + } + + /** + * {@inheritDoc} + * + * @see java.sql.Driver#jdbcCompliant() + */ + @Override + public boolean jdbcCompliant() { + return false; + } + + protected final DriverInfo getDriverInfo() { + return driverInfo; + } + + public void setContextFactory( JcrContextFactory factory ) { + assert factory != null; + this.contextFactory = factory; + } + + public interface JcrContextFactory { + Context createContext( Properties properties ) throws NamingException; + } + +} Index: utils/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/ModeShapeMetaData.java new file mode 100644 =================================================================== --- /dev/null (revision 2552) +++ utils/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/ModeShapeMetaData.java (working copy) @@ -0,0 +1,143 @@ +/* + * ModeShape (http://www.modeshape.org) + * See the COPYRIGHT.txt file distributed with this work for information + * regarding copyright ownership. Some portions may be licensed + * to Red Hat, Inc. under one or more contributor license agreements. + * See the AUTHORS.txt file in the distribution for a full listing of + * individual contributors. + * + * ModeShape is free software. Unless otherwise indicated, all code in ModeShape + * is licensed to you under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * ModeShape is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.modeshape.jdbc; + +/** + * Specialized implementation for ModeShape-specific features. + */ +public class ModeShapeMetaData extends JcrMetaData { + + public ModeShapeMetaData( JcrConnection connection ) { + super(connection); + } + + /** + * {@inheritDoc} + *
+ * ModeShape does support FULL OUTER JOIN
, so this method returns true when this driver connects to a ModeShape
+ * JCR repository.
+ *
+ * ModeShape does support UNION
, so this method returns true when this driver connects to a ModeShape JCR
+ * repository.
+ *
+ * ModeShape does support UNION ALL
, so this method returns true when this driver connects to a ModeShape JCR
+ * repository.
+ *
+ * ModeShape uses arithmetic operations in criteria, and in the current implementation if one operand is null then the
+ * operations returns the other. Therefore, 'null + X = X', so this method returns false
.
+ *
+ * ModeShape definitely uses sort order. Therefore, this method always returns false
.
+ *
+ * ModeShape definitely uses sort order. Therefore, this method always returns false
.
+ *
+ * ModeShape sorts null values to be lower than non-null values. Therefore, this method returns false
.
+ *
+ * ModeShape sorts null values to be lower than non-null values. Therefore, this method returns true
.
+ *
descriptorKey
+ *
+ * @param descriptorKey
+ * @return String descriptor value
+ */
+ String getDescriptor( String descriptorKey );
+
+ /**
+ * Call to get {@link NodeType} based on specified name
+ *
+ * @param name
+ * @return NodeType
+ * @throws RepositoryException
+ */
+ NodeType nodeType( String name ) throws RepositoryException;
+
+ /**
+ * Call to get all the {@link NodeType}s defined.
+ *
+ * @return List of all the node types.
+ * @throws RepositoryException
+ */
+ Listquery
based on the specified Jcr language.
+ *
+ * @param query is the sql query to execute
+ * @param language is the JCR language the query
should be executed based on.
+ * @return QueryResult is the JCR query result
+ * @throws RepositoryException
+ */
+ QueryResult execute( String query,
+ String language ) throws RepositoryException;
+
+ /**
+ * Call to create the connection based on the implementation of this interface.
+ *
+ * @param info the driver information
+ * @return Connection
+ * @throws SQLException
+ * @see java.sql.Driver#connect(String, java.util.Properties)
+ */
+ Connection createConnection( DriverInfo info ) throws SQLException;
+
+ /**
+ * @see java.sql.Connection#commit()
+ * @throws RepositoryException
+ */
+ void commit() throws RepositoryException;
+
+ /**
+ * @see java.sql.Connection#rollback()
+ * @throws RepositoryException
+ */
+ void rollback() throws RepositoryException;
+
+ /**
+ * @see java.sql.Connection#isValid(int)
+ * @param timeout
+ * @return boolean indicating if timeout is valid
+ * @throws RepositoryException
+ */
+ boolean isValid( int timeout ) throws RepositoryException;
+
+ /**
+ * Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that
+ * does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the
+ * result of recursively calling isWrapperFor
on the wrapped object. If this does not implement the interface and
+ * is not a wrapper, return false. This method should be implemented as a low-cost operation compared to unwrap
+ * so that callers can use this method to avoid expensive unwrap
calls that may fail. If this method returns true
+ * then calling unwrap
with the same argument should succeed.
+ *
+ * @param iface a Class defining an interface.
+ * @return true if this implements the interface or directly or indirectly wraps an object that does. for an object with the
+ * given interface.
+ * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
+ */
+ boolean isWrapperFor( Class> iface );
+
+ /**
+ * Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not
+ * exposed by the proxy. If the receiver implements the interface then the result is the receiver or a proxy for the receiver.
+ * If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a
+ * proxy for the wrapped object. Otherwise return the the result of calling unwrap
recursively on the wrapped
+ * object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an
+ * SQLException
is thrown.
+ *
+ * @param iface A Class defining an interface that the result must implement.
+ * @return an object that implements the interface. May be a proxy for the actual implementing object.
+ * @param This class contains constants indicating names of the columns in the + * result sets returned by methods on JcrMetaData. Each inner class represents + * a particular method and the class attributes give the names of the columns on + * methods ResultSet.
+ */ + +public interface JDBCColumnNames { + + /** + * This class contains constants representing column names on ResultSet + * returned by getCatalogs method on DatabaseMetaData. These constant values + * are be used for the column names used in constructing the ResultSet obj. + */ + interface CATALOGS { + // name of the column containing catalog or Virtual database name. + static final String TABLE_CAT = "TABLE_CAT"; //$NON-NLS-1$ + } + + /** + * This class contains constants representing column names on ResultSet + * returned by getColumns method on DatabaseMetaData. These constant values + * are be used to hardcode the column names used in constructin the ResultSet obj. + */ + interface COLUMNS { + + // name of the column containing catalog or Virtual database name. + static final String TABLE_CAT = "TABLE_CAT"; //$NON-NLS-1$ + + // name of the column containing schema or Virtual database version. + static final String TABLE_SCHEM = "TABLE_SCHEM"; //$NON-NLS-1$ + + // name of the column containing table or group name. + static final String TABLE_NAME = "TABLE_NAME"; //$NON-NLS-1$ + + // name of the column containing column or element name. + static final String COLUMN_NAME = "COLUMN_NAME"; //$NON-NLS-1$ + + /** name of column that contains SQL type from java.sql.Types for column's data type. */ + static final String DATA_TYPE = "DATA_TYPE"; //$NON-NLS-1$ + + /** name of column that contains local type name used by the data source. */ + static final String TYPE_NAME = "TYPE_NAME"; //$NON-NLS-1$ + + // name of the column containing column size. + static final String COLUMN_SIZE = "COLUMN_SIZE"; //$NON-NLS-1$ + + /** name of column that is not used will contain nulls */ + static final String BUFFER_LENGTH = "BUFFER_LENGTH"; //$NON-NLS-1$ + + // name of the column containing number of digits to right of decimal + static final String DECIMAL_DIGITS = "DECIMAL_DIGITS"; //$NON-NLS-1$ + + // name of the column containing column's Radix. + static final String NUM_PREC_RADIX = "NUM_PREC_RADIX"; //$NON-NLS-1$ + + /** name of column that has an String value indicating nullablity */ + static final String NULLABLE = "NULLABLE"; //$NON-NLS-1$ + + /** name of column containing explanatory notes. */ + static final String REMARKS = "REMARKS"; //$NON-NLS-1$ + + /** name of column which contails default value for the column. */ + static final String COLUMN_DEF = "COLUMN_DEF"; //$NON-NLS-1$ + + /** name of column that not used will contain nulls */ + static final String SQL_DATA_TYPE = "SQL_DATA_TYPE"; //$NON-NLS-1$ + + /** name of column that not used will contain nulls */ + static final String SQL_DATETIME_SUB = "SQL_DATETIME_SUB"; //$NON-NLS-1$ + + /** name of column that stores the max number of bytes in the column */ + static final String CHAR_OCTET_LENGTH = "CHAR_OCTET_LENGTH"; //$NON-NLS-1$ + + /** name of column that stores the index of a column in the table */ + static final String ORDINAL_POSITION = "ORDINAL_POSITION"; //$NON-NLS-1$ + + /** name of column that has an String value indicating nullablity */ + static final String IS_NULLABLE = "IS_NULLABLE"; //$NON-NLS-1$ + + /** name of column that is the scope of a reference attribute (null if DATA_TYPE isn't REF)*/ + static final String SCOPE_CATLOG = "SCOPE_CATLOG"; //$NON-NLS-1$ + + /** name of column that is the scope of a reference attribute (null if the DATA_TYPE isn't REF) */ + static final String SCOPE_SCHEMA = "SCOPE_SCHEMA"; //$NON-NLS-1$ + + /** name of column that is the scope of a reference attribure (null if the DATA_TYPE isn't REF) */ + static final String SCOPE_TABLE = "SCOPE_TABLE"; //$NON-NLS-1$ + + /** + * name of column that is source type of a distinct type or user-generated Ref type, SQL type + * from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF) + */ + static final String SOURCE_DATA_TYPE = "SOURCE_DATA_TYPE"; //$NON-NLS-1$ + + /** name of column that has an String value indicating format */ + static final String FORMAT = "FORMAT"; //$NON-NLS-1$ + + /** name of column that has an String value indicating minimum range */ + static final String MIN_RANGE = "MIN_RANGE"; //$NON-NLS-1$ + + /** name of column that has an String value indicating maximum range */ + static final String MAX_RANGE = "MAX_RANGE"; //$NON-NLS-1$ + } + + + /** + * This class contains constants representing column names on ResultSet + * returned by getSchemas method on DatabaseMetaData. These constant values + * are be used to hardcode the column names used in constructin the ResultSet obj. + */ + interface SCHEMAS { + + // name of the column containing procedure catalog or Virtual database name. + static final String TABLE_SCHEM = "TABLE_SCHEM"; //$NON-NLS-1$ + + // name of the column containing schema or Virtual database version. + static final String TABLE_CATALOG = "TABLE_CATALOG"; //$NON-NLS-1$ + + } + + /** + * This class contains constants representing column names on ResultSet + * returned by getTables and getTableTypes methods on DatabaseMetaData. These + * constant values are be used to hardcode the column names used in construction + * the ResultSet obj. + */ + interface TABLES { + + // name of the column containing catalog or Virtual database name. + static final String TABLE_CAT = "TABLE_CAT"; //$NON-NLS-1$ + + // name of the column containing schema or Virtual database version. + static final String TABLE_SCHEM = "TABLE_SCHEM"; //$NON-NLS-1$ + + // name of the column containing table or group name. + static final String TABLE_NAME = "TABLE_NAME"; //$NON-NLS-1$ + + // name of the column containing table or group type. + static final String TABLE_TYPE = "TABLE_TYPE"; //$NON-NLS-1$ + + /** name of column containing explanatory notes. */ + static final String REMARKS = "REMARKS"; //$NON-NLS-1$ + static final String TYPE_CAT = "TYPE_CAT"; //$NON-NLS-1$ + static final String TYPE_SCHEM = "TYPE_SCHEM"; //$NON-NLS-1$ + static final String TYPE_NAME = "TYPE_NAME"; //$NON-NLS-1$ + static final String SELF_REFERENCING_COL_NAME = "SELF_REFERENCING_COL_NAME"; //$NON-NLS-1$ + static final String REF_GENERATION = "REF_GENERATION"; //$NON-NLS-1$ + static final String ISPHYSICAL = "ISPHYSICAL"; //$NON-NLS-1$ + + } + + /** + * This class contains constants representing column names on ResultSet + * returned by getTables and getTableTypes methods on DatabaseMetaData. These + * constant values are be used to hardcode the column names used in construction + * the ResultSet obj. + */ + interface TABLE_TYPES { + + // name of the column containing table or group type. + static final String TABLE_TYPE = "TABLE_TYPE"; //$NON-NLS-1$ + } + + /** + * This class contains constants representing column names on ResultSet + * returned by getTypeInfo method on DatabaseMetaData. These constant values + * are be used to hard code the column names used in construction of the ResultSet obj. + */ + interface TYPE_INFO { + + /** name of column that contains local type name used by the data source. */ + static final String TYPE_NAME = "TYPE_NAME"; //$NON-NLS-1$ + + /** name of column that contains SQL type from java.sql.Types for column's data type. */ + static final String DATA_TYPE = "DATA_TYPE"; //$NON-NLS-1$ + + // name of the column containing number of digits to right of decimal + static final String PRECISION = "PRECISION"; //$NON-NLS-1$ + + // name of the column containing prefix used to quote a literal + static final String LITERAL_PREFIX = "LITERAL_PREFIX"; //$NON-NLS-1$ + + // name of the column containing suffix used to quote a literal + static final String LITERAL_SUFFIX = "LITERAL_SUFFIX"; //$NON-NLS-1$ + + // name of the column containing params used in creating the type + static final String CREATE_PARAMS = "CREATE_PARAMS"; //$NON-NLS-1$ + + /** name of column that has an String value indicating nullablity */ + static final String NULLABLE = "NULLABLE"; //$NON-NLS-1$ + + /** name of column that has an String value indicating case sensitivity */ + static final String CASE_SENSITIVE = "CASE_SENSITIVE"; //$NON-NLS-1$ + + /** name of column that has an String value indicating searchability */ + static final String SEARCHABLE = "SEARCHABLE"; //$NON-NLS-1$ + + /** name of column that has an String value indicating searchability */ + static final String UNSIGNED_ATTRIBUTE = "UNSIGNED_ATTRIBUTE"; //$NON-NLS-1$ + + /** name of column that contains info if the column is a currency value */ + static final String FIXED_PREC_SCALE = "FIXED_PREC_SCALE"; //$NON-NLS-1$ + + /** name of column that contains info whether the column is autoincrementable */ + static final String AUTOINCREMENT = "AUTO_INCREMENT"; //$NON-NLS-1$ + + /** name of column that localised version of type name */ + static final String LOCAL_TYPE_NAME = "LOCAL_TYPE_NAME"; //$NON-NLS-1$ + + /** name of column that gives the min scale supported */ + static final String MINIMUM_SCALE = "MINIMUM_SCALE"; //$NON-NLS-1$ + + /** name of column that gives the max scale supported */ + static final String MAXIMUM_SCALE = "MAXIMUM_SCALE"; //$NON-NLS-1$ + + /** name of column that not used will contain nulls */ + static final String SQL_DATA_TYPE = "SQL_DATA_TYPE"; //$NON-NLS-1$ + + /** name of column that not used will contain nulls */ + static final String SQL_DATETIME_SUB = "SQL_DATETIME_SUB"; //$NON-NLS-1$ + + // constant indiacting column's Radix. + static final String NUM_PREC_RADIX = "NUM_PREC_RADIX"; //$NON-NLS-1$ + } + + /** + * This class contains constants representing column names on ResultSet + * returned by getCrossReference, getExportedKeys, and getImportedKeys methods + * on DatabaseMetaData. These constant values are be used to hard code the + * column names used in construction the ResultSet obj. + */ + interface REFERENCE_KEYS { + + // name of the column containing catalog or Virtual database name for primary key's table. + static final String PKTABLE_CAT = "PKTABLE_CAT"; //$NON-NLS-1$ + + // name of the column containing schema or Virtual database version for primary key's table. + static final String PKTABLE_SCHEM = "PKTABLE_SCHEM"; //$NON-NLS-1$ + + // name of the column containing table or group name for primary key's table. + static final String PKTABLE_NAME = "PKTABLE_NAME"; //$NON-NLS-1$ + + // name of the column containing column or element name of the primary key. + static final String PKCOLUMN_NAME = "PKCOLUMN_NAME"; //$NON-NLS-1$ + + // name of the column containing catalog or Virtual database name for foreign key's table. + static final String FKTABLE_CAT = "FKTABLE_CAT"; //$NON-NLS-1$ + + // name of the column containing schema or Virtual database version for foreign key's table. + static final String FKTABLE_SCHEM = "FKTABLE_SCHEM"; //$NON-NLS-1$ + + // name of the column containing table or group name for foreign key's table. + static final String FKTABLE_NAME = "FKTABLE_NAME"; //$NON-NLS-1$ + + // name of the column containing column or element name of the foreign key. + static final String FKCOLUMN_NAME = "FKCOLUMN_NAME"; //$NON-NLS-1$ + + // name of the column containing sequence number within the foreign key + static final String KEY_SEQ = "KEY_SEQ"; //$NON-NLS-1$ + + // name of the column containing effect on foreign key when PK is updated. + static final String UPDATE_RULE = "UPDATE_RULE"; //$NON-NLS-1$ + + // name of the column containing effect on foreign key when PK is deleted. + static final String DELETE_RULE = "DELETE_RULE"; //$NON-NLS-1$ + + // name of the column containing name of the foreign key. + static final String FK_NAME = "FK_NAME"; //$NON-NLS-1$ + + // name of the column containing name of the primary key. + static final String PK_NAME = "PK_NAME"; //$NON-NLS-1$ + + // name of the column containing deferability of foreign key constraStrings. + static final String DEFERRABILITY = "DEFERRABILITY"; //$NON-NLS-1$ + static final String FKPOSITION = "FKPOSITION"; //$NON-NLS-1$ + } + + + /** + * This class contains constants representing column names on ResultSet + * returned by getPrimaryKeys method on DatabaseMetaData. These constant values + * are be used to hard code the column names used in construction the ResultSet obj. + */ + interface PRIMARY_KEYS { + + // name of the column containing catalog or Virtual database name. + static final String TABLE_CAT = "TABLE_CAT"; //$NON-NLS-1$ + + // name of the column containing schema or Virtual database version. + static final String TABLE_SCHEM = "TABLE_SCHEM"; //$NON-NLS-1$ + + // name of the column containing table or group name. + static final String TABLE_NAME = "TABLE_NAME"; //$NON-NLS-1$ + + // name of the column containing column or element name. + static final String COLUMN_NAME = "COLUMN_NAME"; //$NON-NLS-1$ + + // name of the column containing sequence number within the primary key + static final String KEY_SEQ = "KEY_SEQ"; //$NON-NLS-1$ + + // name of the column containing name of the primary key. + static final String PK_NAME = "PK_NAME"; //$NON-NLS-1$ + static final String POSITION = "POSITION"; //$NON-NLS-1$ + } + + /** + * This class contains constants representing column names on ResultSet + * returned by getIndexInfo method on DatabaseMetaData. These constant values + * are be used to hard code the column names used in construction the ResultSet obj. + */ + interface INDEX_INFO { + + // name of the column containing tables catalog name on which the index is present + static final String TABLE_CAT = "TABLE_CAT"; //$NON-NLS-1$ + + // name of the column containing tables schema name on which the index is present + static final String TABLE_SCHEM = "TABLE_SCHEM"; //$NON-NLS-1$ + + // name of the column containing table or group name. + static final String TABLE_NAME = "TABLE_NAME"; //$NON-NLS-1$ + + // name of the column containing name of column showing if an index in non-unique + static final String NON_UNIQUE = "NON_UNIQUE"; //$NON-NLS-1$ + + // name of the column containing name of column containing index_qualifier string + static final String INDEX_QUALIFIER = "INDEX_QUALIFIER"; //$NON-NLS-1$ + + // name of the column containing name of column containing index names + static final String INDEX_NAME = "INDEX_NAME"; //$NON-NLS-1$ + + // name of the column containing name of column containing index types + static final String TYPE = "TYPE"; //$NON-NLS-1$ + + // name of the column containing name of the column containing column position. + static final String ORDINAL_POSITION = "ORDINAL_POSITION"; //$NON-NLS-1$ + + // name of the column containing name of the column containing column names. + static final String COLUMN_NAME = "COLUMN_NAME"; //$NON-NLS-1$ + + // name of the column containing name of column containing info if the index is asc or desc. + static final String ASC_OR_DESC = "ASC_OR_DESC"; //$NON-NLS-1$ + + // name of the column containing name of the column containing number of unique values in index. + static final String CARDINALITY = "CARDINALITY"; //$NON-NLS-1$ + + // name of the column containing name of the column giving number od pages used for the current index. + static final String PAGES = "PAGES"; //$NON-NLS-1$ + + // name of the column containing name of the column giving filter condition. + static final String FILTER_CONDITION = "FILTER_CONDITION"; //$NON-NLS-1$ + } + + + +} Index: utils/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/metadata/JDBCColumnPositions.java new file mode 100644 =================================================================== --- /dev/null (revision 2552) +++ utils/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/metadata/JDBCColumnPositions.java (working copy) @@ -0,0 +1,578 @@ +/* + * ModeShape (http://www.modeshape.org) + * See the COPYRIGHT.txt file distributed with this work for information + * regarding copyright ownership. Some portions may be licensed + * to Red Hat, Inc. under one or more contributor license agreements. + * See the AUTHORS.txt file in the distribution for a full listing of + * individual contributors. + * + * ModeShape is free software. Unless otherwise indicated, all code in ModeShape + * is licensed to you under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * ModeShape is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.modeshape.jdbc.metadata; + +/** + * This class provides constants indicating positions of columns in the
+ * ResultSets
returned by methods on MMDatabaseMetaData
+ * object. The inner classes represent the methods while attributes represent the
+ * column positions. The name of the constant explains the column content.
The constants in the inner classes could include column positions for columns
+ * that are hardcoded, columns positions of some columns on server's
+ * Results
object.
Each of the inner classes have a constant MAX_COLUMNS
that
+ * represents the number of columns to be read from the server's Results
+ * object.
All the column positions are one based. + */ + +public interface JDBCColumnPositions { + + /** + *
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ * JAVA_CLASS
is the column position for element data type on
+ * server's Results object.
+ */
+ interface SCHEMAS {
+ /** Number of columns to be read from results returned getElements method. */
+ static final int MAX_COLUMNS = 2;
+ static final int TABLE_CATALOG = 2;
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ * JAVA_CLASS
is the column position for element data type on
+ * server's Results object.
+ */
+ interface CATALOGS {
+
+ /** Number of columns to be read from results returned getElements method. */
+ static final int MAX_COLUMNS = 1;
+ }
+
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ * JAVA_CLASS
is the column position for element data type on
+ * server's Results object.
+ */
+ interface COLUMNS {
+
+ /** Number of columns to be read from results returned getElements method. */
+ static final int MAX_COLUMNS = 22;
+
+ /** Position of column that contains catalog name in which the table for the column is present. */
+ static final int TABLE_CAT = 1;
+
+ static final int TABLE_SCHEM = 2;
+
+ static final int TABLE_NAME = 3;
+
+ static final int COLUMN_NAME = 4;
+
+ /** Position of column that contains SQL type from java.sql.Types for column's data type. */
+ static final int DATA_TYPE = 5;
+
+ /** Position of column that contains local type name used by the data source. */
+ static final int TYPE_NAME = 6;
+
+ static final int COLUMN_SIZE = 7;
+
+ /** Position of column that is not used will contain nulls */
+ static final int BUFFER_LENGTH = 8;
+
+ static final int DECIMAL_DIGITS = 9;
+
+ static final int NUM_PREC_RADIX = 10;
+
+ /** Position of column that has an int value indicating nullablity */
+ static final int NULLABLE = 11;
+
+ /** Position of column containing explanatory notes. */
+ static final int REMARKS = 12;
+
+ static final int COLUMN_DEF = 13;
+
+ /** Position of column that not used will contain nulls */
+ static final int SQL_DATA_TYPE = 14;
+
+ /** Position of column that not used will contain nulls */
+ static final int SQL_DATETIME_SUB = 15;
+
+ static final int CHAR_OCTET_LENGTH = 16;
+
+ static final int ORDINAL_POSITION = 17;
+
+ /** Position of column that has an String value indicating nullablity */
+ static final int IS_NULLABLE = 18;
+
+ static final int SCOPE_CATALOG = 19;
+
+ static final int SCOPE_SCHEMA = 20;
+
+ static final int SCOPE_TABLE = 21;
+
+ static final int SOURCE_DATA_TYPE = 22;
+
+ static final int IS_AUTOINCREMENT = 23;
+
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ * JAVA_CLASS
is the column position for element data type on
+ * server's Results object.
+ */
+ interface TABLES {
+
+ /** Number of columns to be read from results returned getTables method. */
+ static final int MAX_COLUMNS = 10;
+
+ /** Position of column that contains catalog name in which the table is present. */
+ static final int TABLE_CAT = 1;
+ static final int TYPE_CAT = 6;
+ static final int TYPE_SCHEM = 7;
+ static final int TYPE_NAME = 8;
+ static final int SELF_REFERENCING_COL_NAME = 9;
+ static final int REF_GENERATION = 10;
+ static final int ISPHYSICAL = 11;
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ * JAVA_CLASS
is the column position for element data type on
+ * server's Results object.
+ */
+ interface TYPE_INFO {
+
+ /** Number of columns to be read from results returned getElements method. */
+ static final int MAX_COLUMNS = 18;
+
+ /** Position of column that contains local type name used by the data source. */
+ static final int TYPE_NAME = 1;
+
+ /** Position of column that contains SQL type from java.sql.Types for column's data type. */
+ static final int DATA_TYPE = 2;
+
+ static final int PRECISION = 3;
+ /** Position of column that contains prefix used to quote a literal. */
+ static final int LITERAL_PREFIX = 4;
+
+ /** Position of column that contains suffix used to quote a literal. */
+ static final int LITERAL_SUFFIX = 5;
+
+ /** Position of column that contains params used in creating the type. */
+ static final int CREATE_PARAMS = 6;
+
+ /** Position of column that contains the nullable value. */
+ static final int NULLABLE = 7;
+
+ static final int CASE_SENSITIVE = 8;
+
+ /** Position of column that contains the searchable value. */
+ static final int SEARCHABLE = 9;
+
+ /** Position of column that contains the unsigned value. */
+ static final int UNSIGNED_ATTRIBUTE = 10;
+
+ static final int FIXED_PREC_SCALE = 11;
+
+ static final int AUTO_INCREMENT = 12;
+
+ /** Position of column that contains local type name used by the data source. */
+ static final int LOCAL_TYPE_NAME = 13;
+
+ /** Position of column that contains the min scale value. */
+ static final int MINIMUM_SCALE = 14;
+
+ /** Position of column that contains the max scale value. */
+ static final int MAXIMUM_SCALE = 15;
+
+ /** Position of column that not used will contain nulls */
+ static final int SQL_DATA_TYPE = 16;
+
+ /** Position of column that not used will contain nulls */
+ static final int SQL_DATETIME_SUB = 17;
+
+ static final int NUM_PREC_RADIX = 18;
+
+ /** Position of column in server's results containing name of the datatype.*/
+ static final int NAME = 19;
+
+ /** Position of column in server's results containing isSigned value.*/
+ static final int IS_SIGNED = 20;
+
+ /** Position of column in server's results containing nullType name.*/
+ static final int NULL_TYPE_NAME = 21;
+
+ /** Position of column in server's results containing search type name.*/
+ static final int SEARCH_TYPE_NAME = 22;
+ }
+
+ /**
+ * This class contains constants representing column positions on ResultSet
+ * returned by getUDTS method on DatabaseMetaData. These constant values
+ * are be used to hardcode the column values used in constructin the ResultSet obj.
+ */
+ interface UDTS {
+
+ /** Number of columns to be read from results returned getUserDefinedTypes method. */
+ static final int MAX_COLUMNS = 7;
+
+ // name of the column containing table or Groups name in which UDTS are present.
+ static final int TABLE_NAME = 3;
+
+ // name of the column containing catalog or Virtual database name.
+ static final int TYPE_CAT = 1;
+
+ // name of the column containing schema or Virtual database version.
+ static final int TYPE_SCHEM = 2;
+
+ // name of the column containing name of type name column.
+ static final int TYPE_NAME = 9;
+
+ // name of the column containing class name column.
+ static final int CLASS_NAME = 4;
+
+ // name of the column containing name of sql datatype code column
+ static final int DATA_TYPE = 5;
+
+ // name of the column containing comments column
+ static final int REMARKS = 6;
+
+ static final int BASE_TYPE = 7;
+ /** Position of column in server's results containing java class name.*/
+ static final int JAVA_CLASS = 8;
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getIndexInfo method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from the query against System.KeyElements table.
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ * JAVA_CLASS
is the column position for element data type on
+ * server's Results object.
+ */
+ interface PRIMARY_KEYS {
+
+ /** Number of columns to be read from results returned by getPrimaryKeys. */
+ static final int MAX_COLUMNS = 6;
+
+ /** Position of column that contains catalog name of the primaryTable. */
+ static final int TABLE_CAT = 1;
+ static final int TABLE_SCHEM = 2;
+ static final int TABLE_NAME = 3;
+ static final int COLUMN_NAME = 4;
+ static final int KEY_SEQ = 5;
+ static final int PK_NAME = 6;
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getCrossReferences method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getCrossReferences method on server's Metadata object
.
+ */
+ interface REFERENCE_KEYS {
+
+ /** Number of columns to be read from results returned any of the 3 methods. */
+ static final int MAX_COLUMNS = 14;
+
+ /** Position of column that contains catalog name of the primaryTable. */
+ static final int PKTABLE_CAT = 1;
+
+ /** Position of column that contains scheam name of the primaryTable. */
+ static final int PKTABLE_SCHEM = 2;
+
+ static final int PKTABLE_NAME = 3;
+
+ static final int PKCOLUMN_NAME = 4;
+
+ /** Position of column that contains catalog name of the foreignTable. */
+ static final int FKTABLE_CAT = 5;
+
+ /** Position of column that contains schema name of the foreignTable. */
+ static final int FKTABLE_SCHEM = 6;
+
+ static final int FKTABLE_NAME = 7;
+
+ static final int FKCOLUMN_NAME = 8;
+
+ static final int KEY_SEQ = 9;
+
+ /** Position of column that determines how forein key changes if PK is updated. */
+ static final int UPDATE_RULE = 10;
+
+ /** Position of column that determines how forein key changes if PK is deleted. */
+ static final int DELETE_RULE = 11;
+
+ static final int FK_NAME = 12;
+
+ static final int PK_NAME = 13;
+
+ /** Position of column that determines if forein key constraints can be deffered until commit. */
+ static final int DEFERRABILITY = 14;
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getProcedures method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ * JAVA_CLASS
is the column position for element data type on
+ * server's Results object.
+ */
+ interface PROCEDURES {
+
+ /** Number of columns to be read from results returned getCrossReferences method. */
+ static final int MAX_COLUMNS = 9;
+
+ /** Position of column that contains catalog name of the procedure. */
+ static final int PROCEDURE_CAT = 1;
+ static final int PROCEDURE_SCHEM = 2;
+ static final int PROCEDURE_NAME = 3;
+
+ /** Position of column the is reserved for future use. */
+ static final int RESERVED_1 = 4;
+
+ /** Position of column the is reserved for future use. */
+ static final int RESERVED_2 = 5;
+
+ /** Position of column the is reserved for future use. */
+ static final int RESERVED_3 = 6;
+
+ static final int REMARKS = 7;
+
+ /** Position of column Procedure type. */
+ static final int PROCEDURE_TYPE = 8;
+
+ static final int SPECIFIC_NAME = 9;
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ * JAVA_CLASS
is the column position for element data type on
+ * server's Results object.
+ */
+ interface PROCEDURE_COLUMNS {
+
+ /** Number of columns to be read from results returned getProcedureColumns method. */
+ static final int MAX_COLUMNS = 20;
+
+ /** Position of column that contains catalog name of the procedure. */
+ static final int PROCEDURE_CAT = 1;
+
+ static final int PROCEDURE_SCHEM = 2;
+ static final int PROCEDURE_NAME = 3;
+ static final int COLUMN_NAME = 4;
+
+ /** Position of the column containing column or element type. */
+ static final int COLUMN_TYPE = 5;
+
+ /** Position of column that contains SQL type from java.sql.Types for column's data type. */
+ static final int DATA_TYPE = 6;
+
+ /** Position of column that contains local type name used by the data source. */
+ static final int TYPE_NAME = 7;
+
+ static final int PRECISION = 8;
+ static final int LENGTH = 9;
+ static final int SCALE = 10;
+ static final int RADIX = 11;
+
+ /** Position of column that contains the nullable value. */
+ static final int NULLABLE = 12;
+
+ /** Position of column that contains comments. */
+ static final int REMARKS = 13;
+ static final int COLUMN_DEF = 14;
+
+ static final int SQL_DATA_TYPE = 15;
+ static final int SQL_DATETIME_SUB = 16;
+ static final int CHAR_OCTET_LENGTH = 17;
+
+ static final int ORDINAL_POSITION = 18;
+
+ static final int IS_NULLABLE = 19;
+
+ static final int SPECIFIC_NAME = 20;
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class also has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ */
+ interface TABLE_PRIVILEGES {
+
+ /** Number of columns to be read from results returned getGroupEntitlements method. */
+ static final int MAX_COLUMNS = 6;
+
+ /** Position of VirtualDatabaseName column in server's results object returned by
+ getGroupEntitlements method in User API */
+ static final int VIRTUAL_DATABASE_NAME = 0;
+
+ /** Position of VirtualDatabaseVersion column in server's results object returned by
+ getElementEntitlements method in User API */
+ static final int VIRTUAL_DATABASE_VERSION = 1;
+
+ /** Position of GroupName column in server's results object returned by
+ getGroupEntitlements method in User API */
+ static final int GROUP_NAME = 2;
+
+ /** Position of Grantor column in server's results object returned by
+ getGroupEntitlements method in User API */
+ static final int GRANTOR = 3;
+
+ /** Position of Grantee column in server's results object returned by
+ getGroupEntitlements method in User API */
+ static final int GRANTEE = 4;
+
+ /** Position of Permission column in server's results object returned by
+ getGroupEntitlements method in User API */
+ static final int PERMISSION = 5;
+
+ /** Position of the column containing catalog name info. */
+ static final int TABLE_CAT = 0;
+
+ /** Position of the column containing privilage grantable info. */
+ static final int IS_GRANTABLE = 6;
+ }
+
+ /**
+ *
This class contains constants representing column positions on ResultSet
+ * returned by getColumns method on DatabaseMetaData. The class also has constants
+ * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
+ * MAX_COLUMNS
is the number of columns to be read from server's
+ * results from getElements method on Metadata object
.
+ */
+ interface COLUMN_PRIVILEGES {
+
+ /** Number of columns to be read from results returned getElementEntitlements method. */
+ static final int MAX_COLUMNS = 7;
+
+ /** Position of VirtualDatabaseName column in server's results object returned by
+ getElementEntitlements method in User API */
+ static final int VIRTUAL_DATABASE_NAME = 0;
+
+ /** Position of VirtualDatabaseVersion column in server's results object returned by
+ getElementEntitlements method in User API */
+ static final int VIRTUAL_DATABASE_VERSION = 1;
+
+ /** Position of GroupName column in server's results object returned by
+ getElementEntitlements method in User API */
+ static final int GROUP_NAME = 2;
+
+ /** Position of ElementName column in server's results object returned by
+ getElementEntitlements method in User API */
+ static final int ELEMENT_NAME = 3;
+
+ /** Position of Grantor column in server's results object returned by
+ getElementEntitlements method in User API */
+ static final int GRANTOR = 4;
+
+ /** Position of Grantee column in server's results object returned by
+ getElementEntitlements method in User API */
+ static final int GRANTEE = 5;
+
+ /** Position of Permission column in server's results object returned by
+ getElementEntitlements method in User API */
+ static final int PERMISSION = 6;
+
+ /** Position of the column containing catalog name info. */
+ static final int TABLE_CAT = 0;
+
+ /** Position of the column containing privilage grantable info. */
+ static final int IS_GRANTABLE = 7;
+ }
+
+}
Index: utils/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/metadata/JDBCSQLTypeInfo.java
new file mode 100644
===================================================================
--- /dev/null (revision 2552)
+++ utils/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/metadata/JDBCSQLTypeInfo.java (working copy)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.modeshape.jdbc.metadata;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Time;
+import java.sql.Timestamp;
+
+import javax.lang.model.type.NullType;
+
+
+/**
+ *
This is a helper class used to obtain SQL type information for java types.
+ * The SQL type information is obtained from java.sql.Types class. The integers and
+ * strings returned by methods in this class are based on constants in java.sql.Types.
+ */
+
+public final class JDBCSQLTypeInfo {
+
+
+ // Prevent instantiation
+ private JDBCSQLTypeInfo() {}
+
+ public static final class DefaultDataTypes {
+ public static final String STRING = "string"; //$NON-NLS-1$
+ public static final String BOOLEAN = "boolean"; //$NON-NLS-1$
+ public static final String BYTE = "byte"; //$NON-NLS-1$
+ public static final String SHORT = "short"; //$NON-NLS-1$
+ public static final String CHAR = "char"; //$NON-NLS-1$
+ public static final String INTEGER = "integer"; //$NON-NLS-1$
+ public static final String LONG = "long"; //$NON-NLS-1$
+ public static final String BIG_INTEGER = "biginteger"; //$NON-NLS-1$
+ public static final String FLOAT = "float"; //$NON-NLS-1$
+ public static final String DOUBLE = "double"; //$NON-NLS-1$
+ public static final String BIG_DECIMAL = "bigdecimal"; //$NON-NLS-1$
+ public static final String DATE = "date"; //$NON-NLS-1$
+ public static final String TIME = "time"; //$NON-NLS-1$
+ public static final String TIMESTAMP = "timestamp"; //$NON-NLS-1$
+ public static final String OBJECT = "object"; //$NON-NLS-1$
+ public static final String NULL = "null"; //$NON-NLS-1$
+ public static final String BLOB = "blob"; //$NON-NLS-1$
+ public static final String CLOB = "clob"; //$NON-NLS-1$
+ public static final String XML = "xml"; //$NON-NLS-1$
+ }
+
+ //java class names
+ public static final class DefaultDataClasses {
+ public static final Class
+ * To create the expected results to be used to run a test, use the test and print method: example:
+ * DriverTestUtil.executeTestAndPrint(this.connection, "SELECT * FROM [nt:base]"); This will print the expected results like this:
+ * String[] expected = { "jcr:primaryType[STRING]", "mode:root", "car:Car", "car:Car", "nt:unstructured" } Now copy the expected
+ * results to the test method. Then change the test to run the executeTest method passing in the expected
results:
+ * example: DriverTestUtil.executeTest(this.connection, "SELECT * FROM [nt:base]", expected);
+ *
PS: remember this is a Reader not InputStream, so all the fields read
+ * going to be converted to strings before they returned.
+ *
+ */
+public class ResultSetReader extends StringLineReader {
+ private static final String DEFAULT_DELIM = " "; //$NON-NLS-1$
+
+ JcrResultSet source = null;
+ ResultSetMetaData metadata = null;
+
+ // Number of columns in the result set
+ int columnCount = 0;
+
+ // delimiter between the fields while reading each row
+ String delimiter = null;
+
+ boolean firstTime = true;
+ int[] columnTypes = null;
+
+ private int rowCount=0;
+
+ private boolean compareColumns = true;
+
+
+ public ResultSetReader(JcrResultSet in, boolean compareCols) {
+ this(in, DEFAULT_DELIM, compareCols);
+ }
+
+ public ResultSetReader(ResultSet in, String delimiter, boolean compareCols) {
+ this.source = (JcrResultSet)in;
+ this.delimiter = delimiter;
+ this.compareColumns = compareCols;
+ }
+
+ /**
+ * @see java.io.Reader#close()
+ */
+ @Override
+ public void close() throws IOException {
+ source.close();
+ super.close();
+ }
+
+ /**
+ * Get the next line of results from the ResultSet. The first line will be the
+ * metadata of the resultset and then followed by the result rows. Each row will be
+ * returned as one line.
+ * @return next result line from result set.
+ * @throws IOException
+ */
+ @Override
+ protected String nextLine() throws IOException, SQLException{
+ // try {
+ if (firstTime) {
+ firstTime = false;
+ this.metadata = source.getMetaData();
+ columnCount = metadata.getColumnCount();
+ columnTypes = new int[columnCount];
+ for (int i = 0; i < columnCount; i++) {
+ columnTypes[i] = metadata.getColumnType(i+1);
+ }
+ return resultSetMetaDataToString(metadata, delimiter);
+ }
+
+ // if you get here then we are ready to read the results.
+ if (source.next()) {
+ rowCount++;
+
+ final StringBuffer sb = new StringBuffer();
+ // Walk through column values in this row
+ for (int col = 1; col <= columnCount; col++) {
+ // this does not work when database metadata is being queried
+ if (compareColumns) compareColumn(col);
+
+ final Object anObj = source.getObject(col);
+ if (columnTypes[col-1] == Types.CLOB) {
+ sb.append(anObj != null ? anObj : "null"); //$NON-NLS-1$
+ }
+ else if (columnTypes[col-1] == Types.BLOB) {
+ sb.append(anObj != null ? "BLOB" : "null"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else if (columnTypes[col-1] == Types.SQLXML) {
+ final SQLXML xml = (SQLXML)anObj;
+ sb.append(anObj != null ? prettyPrint(xml) : "null"); //$NON-NLS-1$
+ }
+ else {
+ sb.append(anObj != null ? anObj : "null"); //$NON-NLS-1$
+ }
+ if (col != columnCount) {
+ sb.append(delimiter);
+ }
+ }
+ sb.append("\n"); //$NON-NLS-1$
+ return sb.toString();
+ }
+
+ return null;
+ }
+
+ private void compareColumn(int col) throws SQLException {
+
+ Object objIdx = source.getObject(col);
+
+ String colName = metadata.getColumnName(col);
+ Object objName = source.getObject(colName);
+
+ assertThat(objIdx, is(objName));
+
+ if (objIdx == null) return;
+
+ Value v = source.getValue(col);
+
+ JcrType jcrType = JcrType.builtInTypeMap().get(PropertyType.nameFromValue(v.getType()));
+
+ assertThat(objIdx, IsInstanceOf.instanceOf(jcrType.getRepresentationClass()));
+
+ }
+
+ public int getRowCount() {
+ return rowCount;
+ }
+
+ /**
+ * Get the first line from the result set. This is the resultset metadata line where
+ * we gather the column names and their types.
+ * @param metadata
+ * @param delimiter
+ * @return String
+ * @throws SQLException
+ */
+ public static String resultSetMetaDataToString(ResultSetMetaData metadata, String delimiter) throws SQLException{
+ StringBuffer sb = new StringBuffer();
+ int columnCount = metadata.getColumnCount();
+ for (int col = 1; col <= columnCount; col++) {
+ sb.append(metadata.getColumnName(col))
+ .append("[") //$NON-NLS-1$
+ .append(metadata.getColumnTypeName(col))
+ .append("]"); //$NON-NLS-1$
+ if (col != columnCount) {
+ sb.append(delimiter);
+ }
+ }
+ sb.append("\n"); //$NON-NLS-1$
+ return sb.toString();
+ }
+
+ public static String prettyPrint(SQLXML xml) throws SQLException {
+ try {
+ TransformerFactory transFactory = TransformerFactory.newInstance();
+ transFactory.setAttribute("indent-number", new Integer(2)); //$NON-NLS-1$
+
+ Transformer tf = transFactory.newTransformer();
+ tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
+ tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");//$NON-NLS-1$
+ tf.setOutputProperty(OutputKeys.INDENT, "yes");//$NON-NLS-1$
+ tf.setOutputProperty(OutputKeys.METHOD, "xml");//$NON-NLS-1$
+ tf.setOutputProperty(OutputKeys.STANDALONE, "yes");//$NON-NLS-1$
+ tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ StreamResult xmlOut = new StreamResult(new BufferedOutputStream(out));
+ tf.transform(xml.getSource(StreamSource.class), xmlOut);
+
+ return out.toString();
+ } catch (Exception e) {
+ return xml.getString();
+ }
+ }
+}
Index: utils/modeshape-jdbc-local/src/test/java/org/modeshape/jdbc/util/ResultsComparator.java
new file mode 100644
===================================================================
--- /dev/null (revision 2552)
+++ utils/modeshape-jdbc-local/src/test/java/org/modeshape/jdbc/util/ResultsComparator.java (working copy)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.modeshape.jdbc.util;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+
+
+/**
+ * This class can be used as the base class to write Query tests for
+ * integration testing. Just like the scripted one this one should provide all
+ * those required flexibility in testing.
+ */
+public class ResultsComparator {
+ protected static String DELIMITER = " "; //$NON-NLS-1$
+
+ private ResultSetReader reader = null;
+
+ public boolean compareColumns = true;
+
+
+ public void assertResultsSetEquals(final ResultSet resultSet,final String expected) {
+ assertNotNull(resultSet);
+ ResultSetReader reader = new ResultSetReader(resultSet, DELIMITER, compareColumns);
+ assertReaderEquals(reader, new StringReader(expected));
+ }
+
+
+ public void assertResultsSetEquals(ResultSet resultSet, String[] expected) {
+ assertNotNull(resultSet);
+ ResultSetReader reader = new ResultSetReader(resultSet, DELIMITER, compareColumns);
+ assertReaderEquals(reader, new StringArrayReader(expected));
+ }
+
+ private void assertReaderEquals(Reader expected, Reader reader) {
+ BufferedReader resultReader = new BufferedReader(expected);
+ BufferedReader expectedReader = new BufferedReader(reader);
+ try {
+ compareResults(resultReader, expectedReader);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ resultReader.close();
+ expectedReader.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ protected String read(BufferedReader r, boolean casesensitive) throws IOException {
+ StringBuffer result = new StringBuffer();
+ String s = null;
+ try {
+ while ((s = r.readLine()) != null) {
+ result.append( (casesensitive ? s.trim() : s.trim().toLowerCase()) );
+ result.append("\n"); //$NON-NLS-1$
+ }
+ } finally {
+ r.close();
+ }
+ return result.toString();
+ }
+
+ protected void compareResults(BufferedReader resultReader, BufferedReader expectedReader) throws IOException {
+ assertEquals(read(expectedReader, compareCaseSensitive()) , read(resultReader, compareCaseSensitive()));
+ }
+
+ protected boolean compareCaseSensitive() {
+ return true;
+ }
+
+ public static void printResults(ResultSet results, boolean compareColumns) {
+ assertNotNull(results);
+ if(results == null) {
+ System.out.println("ResultSet is null"); //$NON-NLS-1$
+ return;
+ }
+ int row;
+ try {
+ row = -1;
+ BufferedReader in = new BufferedReader(new ResultSetReader(results, DELIMITER, compareColumns));
+ String line = in.readLine();
+ String nextline = null;
+ System.out.println("String[] expected = {");
+ while(line != null) {
+ row++;
+
+ nextline = in.readLine();
+ if (nextline != null) {
+ System.out.println("\"" + line + "\",");
+ line = nextline;
+ } else {
+ System.out.println("\"" + line + "\"");
+ line = null;
+ }
+
+ }
+ System.out.println("};");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void assertRowCount(int expected) {
+ if (reader != null) {
+ assertEquals(expected, this.reader.getRowCount());
+ }
+ }
+
+ public int getRowCount(ResultSet results) {
+
+ assertNotNull(results);
+ // Count all
+ try {
+ int count = 0;
+ while(results.next()) {
+ count++;
+ }
+ return count;
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void print(String msg) {
+ System.out.println(msg);
+ }
+
+ public void print(Throwable e) {
+ e.printStackTrace();
+ }
+
+
+}
+
+/**
+ * Converts a String Array object into a Reader object.
+ */
+class StringArrayReader extends StringLineReader {
+ String[] source = null;
+ int index = 0;
+
+ public StringArrayReader(String[] src) {
+ this.source = src;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ protected String nextLine() throws IOException {
+ if (index < this.source.length) {
+ return this.source[index++]+"\n"; //$NON-NLS-1$
+ }
+ return null;
+ }
+}
\ No newline at end of file
Index: utils/modeshape-jdbc-local/src/test/java/org/modeshape/jdbc/util/StringLineReader.java
new file mode 100644
===================================================================
--- /dev/null (revision 2552)
+++ utils/modeshape-jdbc-local/src/test/java/org/modeshape/jdbc/util/StringLineReader.java (working copy)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.modeshape.jdbc.util;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.sql.SQLException;
+
+
+/**
+ * Base class for any type of Reader, where data can be read as line by line.
+ * The derived classes just need to extend this class and implement the "nextLine()"
+ * method to get the full "Reader" functionality.
+ *
+ */
+public abstract class StringLineReader extends Reader {
+
+ // Current line which is being fed to the reader
+ String currentLine = null;
+ // Current index of where the reading stopped last time
+ int currentLineIndex = 0;
+
+ boolean closed = false;
+
+ /**
+ * @see java.io.Reader#close()
+ */
+ @SuppressWarnings("unused")
+ @Override
+ public void close() throws IOException {
+ closed = true;
+ }
+
+ /**
+ * @see java.io.Reader#read(char[], int, int)
+ */
+ @Override
+ public int read(char[] cbuf, int off, int len) throws IOException {
+ if (closed) {
+ throw new IllegalStateException("Reader already closed"); //$NON-NLS-1$
+ }
+
+ int srcoff = currentLineIndex;
+ if (currentLine == null || (currentLine != null && (currentLine.length()-currentLineIndex) <= 0)) {
+ try {
+ currentLine = nextLine();
+ } catch (SQLException e) {
+ throw new IOException(e.getLocalizedMessage(), e);
+ }
+ currentLineIndex = 0;
+ srcoff = currentLineIndex;
+ }
+
+ // If we have data available then send it.
+ if (currentLine != null) {
+ // If requested more than one line limit length to one line
+ if (len > (currentLine.length()-currentLineIndex)) {
+ len = (currentLine.length()-currentLineIndex);
+ }
+
+ // Copy the contents to destination.
+ System.arraycopy(currentLine.toCharArray(), srcoff, cbuf, off, len);
+
+ // Now move the current index further
+ currentLineIndex = currentLineIndex+len;
+ return len;
+ }
+ return -1;
+ }
+
+ /**
+ * Get the next line of data from the data source.
+ * @return String
+ * @throws IOException
+ * @throws SQLException
+ */
+ abstract protected String nextLine() throws IOException, SQLException;
+}
Index: utils/modeshape-jdbc-local/src/test/java/org/modeshape/jdbc/util/TestTimestampWithTimezone.java
new file mode 100644
===================================================================
--- /dev/null (revision 2552)
+++ utils/modeshape-jdbc-local/src/test/java/org/modeshape/jdbc/util/TestTimestampWithTimezone.java (working copy)
@@ -0,0 +1,222 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.modeshape.jdbc.util;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.TimeZone;
+import junit.framework.TestCase;
+
+public class TestTimestampWithTimezone extends TestCase {
+
+ /**
+ * Constructor for TestTimestampWithTimezone.
+ *
+ * @param name
+ */
+ public TestTimestampWithTimezone( String name ) {
+ super(name);
+ }
+
+ @Override
+ public void setUp() {
+ TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("America/Chicago")); //$NON-NLS-1$
+ }
+
+ @Override
+ public void tearDown() {
+ TimestampWithTimezone.resetCalendar(null);
+ }
+
+ /**
+ * Ensures that the same calendar fields in different timezones (initially different UTC) can be converted to the same UTC in
+ * the local time zone
+ *
+ * @param startts
+ * @param startnanos
+ * @param starttz
+ * @param endtz
+ * @since 4.3
+ */
+ public void helpTestSame( String startts,
+ int startnanos,
+ String starttz,
+ String endtz ) {
+ try {
+ Timestamp start = getTimestamp(startts, startnanos, starttz);
+ Timestamp end = getTimestamp(startts, startnanos, endtz);
+
+ assertFalse("Initial timestamps should be different UTC times", start.getTime() == end.getTime()); //$NON-NLS-1$
+
+ assertEquals(TimestampWithTimezone.createTimestamp(start, TimeZone.getTimeZone(starttz), Calendar.getInstance())
+ .getTime(), TimestampWithTimezone.createTimestamp(end,
+ TimeZone.getTimeZone(endtz),
+ Calendar.getInstance()).getTime());
+ } catch (ParseException e) {
+ fail(e.toString());
+ }
+ }
+
+ /**
+ * Assuming local time zone of -06:00, change ts to endtz and compare to expected
+ *
+ * @param ts
+ * @param endtz
+ * @param expected
+ * @since 4.3
+ */
+ public void helpTestChange( String ts,
+ String endtz,
+ String expected ) {
+ Timestamp start = Timestamp.valueOf(ts);
+ Calendar target = Calendar.getInstance(TimeZone.getTimeZone(endtz));
+ assertEquals(expected,
+ TimestampWithTimezone.createTimestamp(start, TimeZone.getTimeZone("America/Chicago"), target).toString()); //$NON-NLS-1$
+ }
+
+ /**
+ * @param startts
+ * @param startnanos
+ * @param starttz
+ * @return Timestamp
+ * @throws ParseException
+ * @since 4.3
+ */
+ private Timestamp getTimestamp( String startts,
+ int startnanos,
+ String starttz ) throws ParseException {
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); //$NON-NLS-1$
+ df.setTimeZone(TimeZone.getTimeZone(starttz));
+
+ Timestamp ts = new Timestamp(df.parse(startts).getTime());
+ ts.setNanos(startnanos);
+ return ts;
+ }
+
+ public void testDST() {
+ helpTestSame("2005-10-30 02:39:10", 1, "America/Chicago", //$NON-NLS-1$ //$NON-NLS-2$
+ "GMT-05:00"); //$NON-NLS-1$
+
+ // ambiguous times are defaulted to standard time equivalent
+ helpTestSame("2005-10-30 01:39:10", 1, "America/Chicago", //$NON-NLS-1$ //$NON-NLS-2$
+ "GMT"); //$NON-NLS-1$
+
+ // test to ensure a time not representable in DST is converted correctly
+ helpTestSame("2005-04-03 02:39:10", 1, "GMT", //$NON-NLS-1$ //$NON-NLS-2$
+ "America/Chicago"); //$NON-NLS-1$
+
+ // expected is in DST
+ helpTestChange("2005-10-30 02:39:10.1", "GMT", "2005-10-29 21:39:10.1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ // expected is in standard time
+ helpTestChange("2005-10-30 10:39:10.1", "GMT", "2005-10-30 04:39:10.1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ }
+
+ public void testTimezone() {
+ helpTestSame("2004-06-29 15:39:10", 1, "GMT-06:00", //$NON-NLS-1$ //$NON-NLS-2$
+ "GMT-05:00"); //$NON-NLS-1$
+ }
+
+ public void testTimezone2() {
+ helpTestSame("2004-06-29 15:39:10", 1, "GMT-08:00", //$NON-NLS-1$ //$NON-NLS-2$
+ "GMT-06:00"); //$NON-NLS-1$
+ }
+
+ public void testTimezone3() {
+ helpTestSame("2004-08-31 18:25:54", 1, "Europe/London", //$NON-NLS-1$ //$NON-NLS-2$
+ "GMT"); //$NON-NLS-1$
+ }
+
+ public void testTimezoneOverMidnight() {
+ helpTestSame("2004-06-30 23:39:10", 1, "America/Los_Angeles", //$NON-NLS-1$ //$NON-NLS-2$
+ "America/Chicago"); //$NON-NLS-1$
+ }
+
+ public void testCase2852() {
+ helpTestSame("2005-05-17 22:35:33", 508659, "GMT", //$NON-NLS-1$ //$NON-NLS-2$
+ "America/New_York"); //$NON-NLS-1$
+ }
+
+ public void testCreateDate() {
+ Timestamp t = Timestamp.valueOf("2004-06-30 23:39:10.1201"); //$NON-NLS-1$
+ Date date = TimestampWithTimezone.createDate(t);
+
+ Calendar cal = Calendar.getInstance();
+
+ cal.setTimeInMillis(date.getTime());
+
+ assertEquals(cal.get(Calendar.HOUR_OF_DAY), 0);
+ assertEquals(cal.get(Calendar.MINUTE), 0);
+ assertEquals(cal.get(Calendar.SECOND), 0);
+ assertEquals(cal.get(Calendar.MILLISECOND), 0);
+ assertEquals(cal.get(Calendar.YEAR), 2004);
+ assertEquals(cal.get(Calendar.MONTH), Calendar.JUNE);
+ assertEquals(cal.get(Calendar.DATE), 30);
+ }
+
+ public void testCreateTime() {
+ Timestamp t = Timestamp.valueOf("2004-06-30 23:39:10.1201"); //$NON-NLS-1$
+ Time date = TimestampWithTimezone.createTime(t);
+
+ Calendar cal = Calendar.getInstance();
+
+ cal.setTimeInMillis(date.getTime());
+
+ assertEquals(cal.get(Calendar.HOUR_OF_DAY), 23);
+ assertEquals(cal.get(Calendar.MINUTE), 39);
+ assertEquals(cal.get(Calendar.SECOND), 10);
+ assertEquals(cal.get(Calendar.MILLISECOND), 0);
+ assertEquals(cal.get(Calendar.YEAR), 2004);
+ assertEquals(cal.get(Calendar.MONTH), Calendar.JUNE);
+ assertEquals(cal.get(Calendar.DATE), 30);
+ }
+
+ /**
+ * Even though the id of the timezones are different, this should not change the result
+ */
+ public void testDateToDateConversion() {
+ Date t = Date.valueOf("2004-06-30"); //$NON-NLS-1$
+ Date converted = TimestampWithTimezone.createDate(t,
+ TimeZone.getTimeZone("America/Chicago"), Calendar.getInstance(TimeZone.getTimeZone("US/Central"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertEquals(t.getTime(), converted.getTime());
+ }
+
+ public void testDateToDateConversion1() {
+ Date t = Date.valueOf("2004-06-30"); //$NON-NLS-1$
+ Date converted = TimestampWithTimezone.createDate(t,
+ TimeZone.getTimeZone("America/Chicago"), Calendar.getInstance(TimeZone.getTimeZone("GMT"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(converted);
+
+ assertEquals(0, cal.get(Calendar.MILLISECOND));
+ }
+
+}
Index: utils/modeshape-jdbc-local/src/test/resources/carConfigRepository.xml
new file mode 100644
===================================================================
--- /dev/null (revision 2552)
+++ utils/modeshape-jdbc-local/src/test/resources/carConfigRepository.xml (working copy)
@@ -0,0 +1,52 @@
+
+
+
- * This method pre-processes the supplied SQL-compatible query and returns the corresponding JCR-SQL2.
- *
* The driver accepts several URL formats based on how the repository is configured:
- *
* Connection URLs
*
- *
* jdbc:jcr:jndi:{jndiName}
*
@@ -59,231 +49,68 @@ import org.modeshape.jdbc.util.Collections;
*
* where
*
- *
* Note that any use of URL encoding ('%' followed by a two-digit hexadecimal value) will be decoded before being used.
*
- * Here's an example of a URL that defines a {@link Repository} instance located at "jcr/local
" with a
- * repository name of "repository" and a user, password of "secret", and workspace name of "My Workspace":
+ * Here's an example of a URL that defines a {@link Repository} instance located at "jcr/local
" with a repository
+ * name of "repository" and a user, password of "secret", and workspace name of "My Workspace":
*
*
* jdbc:jcr:jndi:jcr/local?repositoryName=repository&user=jsmith&password=secret&workspace=My%20Workspace ** - * The "repository" property is required only if the object in JNDI is a {@literal org.modeshape.jcr.api.Repositories} object. - *
* jdbc:jcr:http://{hostname}:{port}?{firstProperty}&{secondProperty}&... *+ * * where *
- * Note that if the supplied properties and URL contain properties with the same name, the value from the supplied Properties - * object will take precedence. - *
- * - * @see java.sql.Driver#connect(java.lang.String, java.util.Properties) - */ - @Override - public Connection connect( String url, - Properties info ) throws SQLException { - - return RepositoryDelegateFactory.createRepositoryDelegate(url, info, this.contextFactory).createConnection(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.Driver#getMajorVersion() - */ - @Override - public int getMajorVersion() { - return getDriverMetadata().getMajorVersion(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.Driver#getMinorVersion() - */ - @Override - public int getMinorVersion() { - return getDriverMetadata().getMinorVersion(); - } - - public String getVendorName() { - return getDriverMetadata().getVendorName(); - } - - public String getVendorUrl() { - return getDriverMetadata().getVendorUrl(); - } - - public String getVersion() { - return getDriverMetadata().getVersion(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.Driver#jdbcCompliant() - */ - @Override - public boolean jdbcCompliant() { - return false; - } - - - static DriverMetadata getDriverMetadata() { - if (driverMetadata == null) { - driverMetadata = new DriverMetadata(); - } - return driverMetadata; - } - - static class DriverMetadata { - private final int major; - private final int minor; - - protected DriverMetadata() { - String[] coords = getVersion().split("[.-]"); - this.major = Integer.parseInt(coords[0]); - this.minor = Integer.parseInt(coords[1]); - } - - public String getVendorName() { - return JdbcI18n.driverVendor.text(); - } - - public String getVendorUrl() { - return JdbcI18n.driverVendorUrl.text(); - } - - public String getVersion() { - return JdbcI18n.driverVersion.text(); - } - - public int getMajorVersion() { - return major; - } - - public int getMinorVersion() { - return minor; - } - - public String getName() { - return JdbcI18n.driverName.text(); - } - } - - public void setContextFactory( JcrContextFactory factory ) { - assert factory != null; - this.contextFactory = factory; - } - - public interface JcrContextFactory { - Context createContext( Properties properties ) throws NamingException; - } - - - } Index: utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/JcrMetaData.java deleted file mode 100644 =================================================================== --- utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/JcrMetaData.java (revision 2552) +++ /dev/null (working copy) @@ -1,2962 +0,0 @@ -/* - * ModeShape (http://www.modeshape.org) - * See the COPYRIGHT.txt file distributed with this work for information - * regarding copyright ownership. Some portions may be licensed - * to Red Hat, Inc. under one or more contributor license agreements. - * See the AUTHORS.txt file in the distribution for a full listing of - * individual contributors. - * - * ModeShape is free software. Unless otherwise indicated, all code in ModeShape - * is licensed to you under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * ModeShape is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.modeshape.jdbc; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.RowIdLifetime; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import javax.jcr.PropertyType; -import javax.jcr.Repository; -import javax.jcr.RepositoryException; -import javax.jcr.Value; -import javax.jcr.nodetype.NodeType; -import javax.jcr.nodetype.PropertyDefinition; -import javax.jcr.query.QueryResult; -import javax.jcr.version.OnParentVersionAction; -import org.modeshape.jdbc.metadata.JDBCColumnNames; -import org.modeshape.jdbc.metadata.JDBCColumnPositions; -import org.modeshape.jdbc.metadata.MetaDataQueryResult; -import org.modeshape.jdbc.metadata.MetadataProvider; -import org.modeshape.jdbc.metadata.ResultSetMetaDataImpl; -import org.modeshape.jdbc.metadata.ResultsMetadataConstants; - -/** - * This driver's implementation of JDBC {@link DatabaseMetaData}. - */ -public class JcrMetaData implements DatabaseMetaData { - - protected static final List- * This driver maps the repository name as the JDBC catalog name. Therefore, this method returns 'Repository' for the catalog - * term. - *
- * - * @see java.sql.DatabaseMetaData#getCatalogTerm() - */ - @Override - public String getCatalogTerm() { - return "Repository"; - } - - /** - * {@inheritDoc} - *- * This driver maps the repository name as the JDBC catalog name. Therefore, this method returns a result set containing only - * the repository's name. - *
- * - * @see java.sql.DatabaseMetaData#getCatalogs() - */ - @SuppressWarnings( "unchecked" ) - @Override - public ResultSet getCatalogs() throws SQLException { - List- * This driver maps REFERENCE properties as keys, and therefore it represents as imported keys those REFERENCE properties on - * the type identified by the table name. - *
- * - * @see java.sql.DatabaseMetaData#getExportedKeys(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public ResultSet getExportedKeys( String catalog, - String schema, - String table ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getExtraNameCharacters() - */ - @Override - public String getExtraNameCharacters() { - return null; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getFunctionColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public ResultSet getFunctionColumns( String catalog, - String schemaPattern, - String functionNamePattern, - String columnNamePattern ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getFunctions(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public ResultSet getFunctions( String catalog, - String schemaPattern, - String functionNamePattern ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - *- * JCR-SQL2 allows identifiers to be surrounded by matching single quotes, double quotes, or opening and closing square - * brackets. Therefore, this method returns a single-quote character as the quote string. - *
- * - * @see java.sql.DatabaseMetaData#getIdentifierQuoteString() - */ - @Override - public String getIdentifierQuoteString() { - return "\""; - } - - /** - * {@inheritDoc} - *- * This driver maps REFERENCE properties as keys, and therefore it represents as imported keys those properties on other types - * referencing the type identified by the table name. - *
- * - * @see java.sql.DatabaseMetaData#getImportedKeys(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public ResultSet getImportedKeys( String catalog, - String schema, - String table ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getIndexInfo(java.lang.String, java.lang.String, java.lang.String, boolean, boolean) - */ - @SuppressWarnings( "unchecked" ) - @Override - public ResultSet getIndexInfo( String catalog, - String schema, - String tableNamePattern, - boolean unique, - boolean approximate ) throws SQLException { - - // Get index information for all tables if tableNamePattern is null - if (tableNamePattern == null) tableNamePattern = WILDCARD; - - Map, Object>[] metadataList = new Map[JDBCColumnPositions.INDEX_INFO.MAX_COLUMNS]; - metadataList[0] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.TABLE_CAT, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - metadataList[1] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.TABLE_SCHEM, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - metadataList[2] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.TABLE_NAME, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NOT_NULL, - this.connection); - metadataList[3] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.NON_UNIQUE, - JcrType.DefaultDataTypes.BOOLEAN, - ResultsMetadataConstants.NULL_TYPES.NOT_NULL, - this.connection); - metadataList[4] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.INDEX_QUALIFIER, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - metadataList[5] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.INDEX_NAME, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - metadataList[6] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.TYPE, - JcrType.DefaultDataTypes.LONG, - ResultsMetadataConstants.NULL_TYPES.NOT_NULL, - this.connection); - metadataList[7] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.ORDINAL_POSITION, - JcrType.DefaultDataTypes.LONG, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - metadataList[8] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.COLUMN_NAME, - JcrType.DefaultDataTypes.LONG, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - metadataList[9] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.ASC_OR_DESC, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - - metadataList[10] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.CARDINALITY, - JcrType.DefaultDataTypes.LONG, - ResultsMetadataConstants.NULL_TYPES.NOT_NULL, - this.connection); - metadataList[11] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.PAGES, - JcrType.DefaultDataTypes.LONG, - ResultsMetadataConstants.NULL_TYPES.NOT_NULL, - this.connection); - metadataList[12] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.INDEX_INFO.FILTER_CONDITION, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - - try { - Boolean nonUnique = Boolean.FALSE; - List- * There is no maximum length of binary literals (or if there is a limit it is not known), so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxBinaryLiteralLength() - */ - @Override - public int getMaxBinaryLiteralLength() { - return JcrMetaData.NO_LIMIT; // no limit - } - - /** - * {@inheritDoc} - *- * There is no maximum length of the catalog (repository) names - or the limit is not known. - *
- * - * @see java.sql.DatabaseMetaData#getMaxCatalogNameLength() - */ - @Override - public int getMaxCatalogNameLength() { - return JcrMetaData.NO_LIMIT; // none - } - - /** - * {@inheritDoc} - *- * There is no maximum length of character literals (or if there is a limit it is not known), so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxCharLiteralLength() - */ - @Override - public int getMaxCharLiteralLength() { - return JcrMetaData.NO_LIMIT; - } - - /** - * {@inheritDoc} - *- * There is no maximum length of column names (or if there is a limit it is not known), so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxColumnNameLength() - */ - @Override - public int getMaxColumnNameLength() { - return JcrMetaData.NO_LIMIT; // no limit - } - - /** - * {@inheritDoc} - *- * JCR-SQL2 does not support GROUP BY, so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxColumnsInGroupBy() - */ - @Override - public int getMaxColumnsInGroupBy() { - return 0; - } - - /** - * {@inheritDoc} - *- * There is no limit to the number of columns in an index (or if there is a limit it is not known), so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxColumnsInIndex() - */ - @Override - public int getMaxColumnsInIndex() { - return JcrMetaData.NO_LIMIT; // no limit - } - - /** - * {@inheritDoc} - *- * There is no limit to the number of columns in an ORDER BY statement (or if there is a limit it is not known), so this - * method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxColumnsInOrderBy() - */ - @Override - public int getMaxColumnsInOrderBy() { - return JcrMetaData.NO_LIMIT; // not known (technically there is no limit, but there would be a practical limit) - } - - /** - * {@inheritDoc} - *- * There is no limit to the number of columns in a select statement (or if there is a limit it is not known), so this method - * returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxColumnsInSelect() - */ - @Override - public int getMaxColumnsInSelect() { - return JcrMetaData.NO_LIMIT; // no limit - } - - /** - * {@inheritDoc} - *- * There is no limit to the number of columns in a table (or if there is a limit it is not known), so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxColumnsInTable() - */ - @Override - public int getMaxColumnsInTable() { - return JcrMetaData.NO_LIMIT; // no limit - } - - /** - * {@inheritDoc} - *- * There is no limit to the number of connections (or if there is a limit it is not known), so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxConnections() - */ - @Override - public int getMaxConnections() { - return JcrMetaData.NO_LIMIT; // no limit - } - - /** - * {@inheritDoc} - *- * There are no cursors (or there is no limit), so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxCursorNameLength() - */ - @Override - public int getMaxCursorNameLength() { - return 0; - } - - /** - * {@inheritDoc} - *- * There are no indexes (or there is no limit), so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxIndexLength() - */ - @Override - public int getMaxIndexLength() { - return 0; // no limit - } - - /** - * {@inheritDoc} - *- * There are no procedures, so this method returns 0. - *
- * - * @see java.sql.DatabaseMetaData#getMaxProcedureNameLength() - */ - @Override - public int getMaxProcedureNameLength() { - return 0; // no limit - } - - /** - * {@inheritDoc} - *- * There is no maximum row size. - *
- * - * @see java.sql.DatabaseMetaData#getMaxRowSize() - */ - @Override - public int getMaxRowSize() { - return JcrMetaData.NO_LIMIT; // no limit - } - - /** - * {@inheritDoc} - *- * There is no maximum length of the schema (workspace) names - or the limit is not known. - *
- * - * @see java.sql.DatabaseMetaData#getMaxSchemaNameLength() - */ - @Override - public int getMaxSchemaNameLength() { - return JcrMetaData.NO_LIMIT; // none - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getMaxStatementLength() - */ - @Override - public int getMaxStatementLength() { - return 0; // no limit - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getMaxStatements() - */ - @Override - public int getMaxStatements() { - return 0; // no limit - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getMaxTableNameLength() - */ - @Override - public int getMaxTableNameLength() { - return 0; // no limit - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getMaxTablesInSelect() - */ - @Override - public int getMaxTablesInSelect() { - return 0; // not known (technically there is no limit, but there would be a practical limit) - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getMaxUserNameLength() - */ - @Override - public int getMaxUserNameLength() { - return 0; // no limit - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getNumericFunctions() - */ - @Override - public String getNumericFunctions() { - return null; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getPrimaryKeys(java.lang.String, java.lang.String, java.lang.String) - */ - @SuppressWarnings( "unchecked" ) - @Override - public ResultSet getPrimaryKeys( String catalog, - String schema, - String tableNamePattern ) throws SQLException { - // Get primary keys for all tables if tableNamePattern is null - if (tableNamePattern == null) tableNamePattern = WILDCARD; - - Map, Object>[] metadataList = new Map[JDBCColumnPositions.PRIMARY_KEYS.MAX_COLUMNS]; - metadataList[0] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.PRIMARY_KEYS.TABLE_CAT, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - metadataList[1] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.PRIMARY_KEYS.TABLE_SCHEM, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - metadataList[2] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.PRIMARY_KEYS.TABLE_NAME, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NOT_NULL, - this.connection); - metadataList[3] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.PRIMARY_KEYS.COLUMN_NAME, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NOT_NULL, - this.connection); - metadataList[4] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.PRIMARY_KEYS.KEY_SEQ, - JcrType.DefaultDataTypes.LONG, - ResultsMetadataConstants.NULL_TYPES.NOT_NULL, - this.connection); - metadataList[5] = MetadataProvider.getColumnMetadata(catalogName, - null, - JDBCColumnNames.PRIMARY_KEYS.PK_NAME, - JcrType.DefaultDataTypes.STRING, - ResultsMetadataConstants.NULL_TYPES.NULLABLE, - this.connection); - - try { - List- * This method returns the effective URL of the connection, which includes all connection properties (even if those properties - * were passed in via the Properties argument). Note that each character in the password is replaced with a '*' character. - *
- * - * @see java.sql.DatabaseMetaData#getURL() - */ - @Override - public String getURL() { - return connection.info().getEffectiveUrl(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getUserName() - */ - @Override - public String getUserName() { - return connection.info().getUsername(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#getVersionColumns(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public ResultSet getVersionColumns( String catalog, - String schema, - String table ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#insertsAreDetected(int) - */ - @Override - public boolean insertsAreDetected( int type ) { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#isCatalogAtStart() - */ - @Override - public boolean isCatalogAtStart() { - return true; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#locatorsUpdateCopy() - */ - @Override - public boolean locatorsUpdateCopy() { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#nullPlusNonNullIsNull() - */ - @Override - public boolean nullPlusNonNullIsNull() { - return false; - } - - /** - * {@inheritDoc} - *- * Assumed to be false for JCR implementations (meaning that sort order IS used), though section 6.7.37 of JCR 2.0 - * specification says ordering of null values is implementation-determined. - *
- * - * @see java.sql.DatabaseMetaData#nullsAreSortedAtEnd() - */ - @Override - public boolean nullsAreSortedAtEnd() { - return false; - } - - /** - * {@inheritDoc} - *- * Assumed to be false for JCR implementations (meaning that sort order IS used), though section 6.7.37 of JCR 2.0 - * specification says ordering of null values is implementation-determined. - *
- * - * @see java.sql.DatabaseMetaData#nullsAreSortedAtStart() - */ - @Override - public boolean nullsAreSortedAtStart() { - return false; - } - - /** - * {@inheritDoc} - *- * Assumed to be false for JCR implementations, though section 6.7.37 of JCR 2.0 specification says ordering of null values is - * implementation-determined. - *
- * - * @see java.sql.DatabaseMetaData#nullsAreSortedHigh() - */ - @Override - public boolean nullsAreSortedHigh() { - return false; - } - - /** - * {@inheritDoc} - *- * Assumed to be true for JCR implementations, though section 6.7.37 of JCR 2.0 specification says ordering of null values is - * implementation-determined. - *
- * - * @see java.sql.DatabaseMetaData#nullsAreSortedLow() - */ - @Override - public boolean nullsAreSortedLow() { - return true; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#othersDeletesAreVisible(int) - */ - @Override - public boolean othersDeletesAreVisible( int type ) { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#othersInsertsAreVisible(int) - */ - @Override - public boolean othersInsertsAreVisible( int type ) { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#othersUpdatesAreVisible(int) - */ - @Override - public boolean othersUpdatesAreVisible( int type ) { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#ownDeletesAreVisible(int) - */ - @Override - public boolean ownDeletesAreVisible( int type ) { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#ownInsertsAreVisible(int) - */ - @Override - public boolean ownInsertsAreVisible( int type ) { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#ownUpdatesAreVisible(int) - */ - @Override - public boolean ownUpdatesAreVisible( int type ) { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#storesLowerCaseIdentifiers() - */ - @Override - public boolean storesLowerCaseIdentifiers() { - return false; // JCR node types are case-sensitive - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#storesLowerCaseQuotedIdentifiers() - */ - @Override - public boolean storesLowerCaseQuotedIdentifiers() { - return false; // JCR node types are case-sensitive - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#storesMixedCaseIdentifiers() - */ - @Override - public boolean storesMixedCaseIdentifiers() { - return false; // JCR node types are case-sensitive - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#storesMixedCaseQuotedIdentifiers() - */ - @Override - public boolean storesMixedCaseQuotedIdentifiers() { - return false; // JCR node types are case-sensitive - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#storesUpperCaseIdentifiers() - */ - @Override - public boolean storesUpperCaseIdentifiers() { - return false; // JCR node types are case-sensitive - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#storesUpperCaseQuotedIdentifiers() - */ - @Override - public boolean storesUpperCaseQuotedIdentifiers() { - return false; // JCR node types are case-sensitive - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsANSI92EntryLevelSQL() - */ - @Override - public boolean supportsANSI92EntryLevelSQL() { - return false; // JCR-SQL2 is not entry-level ANSI92 SQL - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsANSI92FullSQL() - */ - @Override - public boolean supportsANSI92FullSQL() { - return false; // JCR-SQL2 is not full ANSI92 SQL - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsANSI92IntermediateSQL() - */ - @Override - public boolean supportsANSI92IntermediateSQL() { - return false; // JCR-SQL2 is not intermediate ANSI92 SQL - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsAlterTableWithAddColumn() - */ - @Override - public boolean supportsAlterTableWithAddColumn() { - // Not in JCR-SQL2 - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsAlterTableWithDropColumn() - */ - @Override - public boolean supportsAlterTableWithDropColumn() { - // Not in JCR-SQL2 - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsBatchUpdates() - */ - @Override - public boolean supportsBatchUpdates() { - // Not in JCR-SQL2 - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsCatalogsInDataManipulation() - */ - @Override - public boolean supportsCatalogsInDataManipulation() { - // Not in JCR-SQL2 - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsCatalogsInIndexDefinitions() - */ - @Override - public boolean supportsCatalogsInIndexDefinitions() { - // No such thing in JCR-SQL2 - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsCatalogsInPrivilegeDefinitions() - */ - @Override - public boolean supportsCatalogsInPrivilegeDefinitions() { - // No defining privileges in JCR 1.0 or 2.0 or JCR-SQL2 - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsCatalogsInProcedureCalls() - */ - @Override - public boolean supportsCatalogsInProcedureCalls() { - // No such thing in JCR-SQL2 - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsCatalogsInTableDefinitions() - */ - @Override - public boolean supportsCatalogsInTableDefinitions() { - // No defining tables in JCR 1.0 or 2.0 or JCR-SQL2 - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsColumnAliasing() - */ - @Override - public boolean supportsColumnAliasing() { - // JCR-SQL2 does support aliases on column names (section 6.7.39) - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsConvert() - */ - @Override - public boolean supportsConvert() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsConvert(int, int) - */ - @Override - public boolean supportsConvert( int fromType, - int toType ) { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsCoreSQLGrammar() - */ - @Override - public boolean supportsCoreSQLGrammar() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsCorrelatedSubqueries() - */ - @Override - public boolean supportsCorrelatedSubqueries() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsDataDefinitionAndDataManipulationTransactions() - */ - @Override - public boolean supportsDataDefinitionAndDataManipulationTransactions() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsDataManipulationTransactionsOnly() - */ - @Override - public boolean supportsDataManipulationTransactionsOnly() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsDifferentTableCorrelationNames() - */ - @Override - public boolean supportsDifferentTableCorrelationNames() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsExpressionsInOrderBy() - */ - @Override - public boolean supportsExpressionsInOrderBy() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsExtendedSQLGrammar() - */ - @Override - public boolean supportsExtendedSQLGrammar() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsFullOuterJoins() - */ - @Override - public boolean supportsFullOuterJoins() { - // JCR-SQL2 does not support FULL OUTER JOIN ... - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsGetGeneratedKeys() - */ - @Override - public boolean supportsGetGeneratedKeys() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsGroupBy() - */ - @Override - public boolean supportsGroupBy() { - return false; // not in JCR-SQL2; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsGroupByBeyondSelect() - */ - @Override - public boolean supportsGroupByBeyondSelect() { - return false; // not in JCR-SQL2; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsGroupByUnrelated() - */ - @Override - public boolean supportsGroupByUnrelated() { - return false; // not in JCR-SQL2; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsIntegrityEnhancementFacility() - */ - @Override - public boolean supportsIntegrityEnhancementFacility() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsLikeEscapeClause() - */ - @Override - public boolean supportsLikeEscapeClause() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsLimitedOuterJoins() - */ - @Override - public boolean supportsLimitedOuterJoins() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsMinimumSQLGrammar() - */ - @Override - public boolean supportsMinimumSQLGrammar() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsMixedCaseIdentifiers() - */ - @Override - public boolean supportsMixedCaseIdentifiers() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsMixedCaseQuotedIdentifiers() - */ - @Override - public boolean supportsMixedCaseQuotedIdentifiers() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsMultipleOpenResults() - */ - @Override - public boolean supportsMultipleOpenResults() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsMultipleResultSets() - */ - @Override - public boolean supportsMultipleResultSets() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsMultipleTransactions() - */ - @Override - public boolean supportsMultipleTransactions() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsNamedParameters() - */ - @Override - public boolean supportsNamedParameters() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsNonNullableColumns() - */ - @Override - public boolean supportsNonNullableColumns() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsOpenCursorsAcrossCommit() - */ - @Override - public boolean supportsOpenCursorsAcrossCommit() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsOpenCursorsAcrossRollback() - */ - @Override - public boolean supportsOpenCursorsAcrossRollback() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsOpenStatementsAcrossCommit() - */ - @Override - public boolean supportsOpenStatementsAcrossCommit() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsOpenStatementsAcrossRollback() - */ - @Override - public boolean supportsOpenStatementsAcrossRollback() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsOrderByUnrelated() - */ - @Override - public boolean supportsOrderByUnrelated() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsOuterJoins() - */ - @Override - public boolean supportsOuterJoins() { - return true; // JCR-SQL2 - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsPositionedDelete() - */ - @Override - public boolean supportsPositionedDelete() { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsPositionedUpdate() - */ - @Override - public boolean supportsPositionedUpdate() { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsResultSetConcurrency(int, int) - */ - @Override - public boolean supportsResultSetConcurrency( int type, - int concurrency ) { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsResultSetHoldability(int) - */ - @Override - public boolean supportsResultSetHoldability( int holdability ) { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsResultSetType(int) - */ - @Override - public boolean supportsResultSetType( int type ) { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSavepoints() - */ - @Override - public boolean supportsSavepoints() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSchemasInDataManipulation() - */ - @Override - public boolean supportsSchemasInDataManipulation() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSchemasInIndexDefinitions() - */ - @Override - public boolean supportsSchemasInIndexDefinitions() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSchemasInPrivilegeDefinitions() - */ - @Override - public boolean supportsSchemasInPrivilegeDefinitions() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSchemasInProcedureCalls() - */ - @Override - public boolean supportsSchemasInProcedureCalls() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSchemasInTableDefinitions() - */ - @Override - public boolean supportsSchemasInTableDefinitions() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSelectForUpdate() - */ - @Override - public boolean supportsSelectForUpdate() { - return false; // read-only - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsStatementPooling() - */ - @Override - public boolean supportsStatementPooling() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsStoredFunctionsUsingCallSyntax() - */ - @Override - public boolean supportsStoredFunctionsUsingCallSyntax() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsStoredProcedures() - */ - @Override - public boolean supportsStoredProcedures() { - return false; // nope - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSubqueriesInComparisons() - */ - @Override - public boolean supportsSubqueriesInComparisons() { - return false; // no subqueries in JCR-SQL2 - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSubqueriesInExists() - */ - @Override - public boolean supportsSubqueriesInExists() { - return false; // no subqueries in JCR-SQL2 - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSubqueriesInIns() - */ - @Override - public boolean supportsSubqueriesInIns() { - return false; // no subqueries in JCR-SQL2 - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsSubqueriesInQuantifieds() - */ - @Override - public boolean supportsSubqueriesInQuantifieds() { - return false; // no subqueries in JCR-SQL2 - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsTableCorrelationNames() - */ - @Override - public boolean supportsTableCorrelationNames() { - // JCR-SQL2 does support table aliases that can be used as prefixes for column names - return true; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsTransactionIsolationLevel(int) - */ - @Override - public boolean supportsTransactionIsolationLevel( int level ) { - return level == Connection.TRANSACTION_READ_COMMITTED; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsTransactions() - */ - @Override - public boolean supportsTransactions() { - // Generally, JCR does support transactions ... - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsUnion() - */ - @Override - public boolean supportsUnion() { - // JCR-SQL2 does not support UNION ... - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#supportsUnionAll() - */ - @Override - public boolean supportsUnionAll() { - // JCR-SQL2 does not support UNION ALL ... - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#updatesAreDetected(int) - */ - @Override - public boolean updatesAreDetected( int type ) { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#usesLocalFilePerTable() - */ - @Override - public boolean usesLocalFilePerTable() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.DatabaseMetaData#usesLocalFiles() - */ - @Override - public boolean usesLocalFiles() { - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) - */ - @Override - public boolean isWrapperFor( Class> iface ) { - return iface.isInstance(this); - } - - /** - * {@inheritDoc} - * - * @see java.sql.Wrapper#unwrap(java.lang.Class) - */ - @Override - public- * This driver only supports {@link ResultSet#TYPE_FORWARD_ONLY}. - *
- * - * @see java.sql.ResultSet#getType() - */ - @Override - public int getType() throws SQLException { - notClosed(); - return ResultSet.TYPE_FORWARD_ONLY; - } - - /** - * {@inheritDoc} - *- * This driver only supports {@link ResultSet#FETCH_FORWARD}. - *
- * - * @see java.sql.ResultSet#getFetchDirection() - */ - @Override - public int getFetchDirection() throws SQLException { - notClosed(); - return ResultSet.FETCH_FORWARD; - } - - /** - * {@inheritDoc} - *- * This method, when called on an open result set, will have no effect on the fetch direction because this driver only - * supports {@link ResultSet#FETCH_FORWARD}. - *
- * - * @see java.sql.ResultSet#setFetchDirection(int) - */ - @Override - public void setFetchDirection( int direction ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - *- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports - * {@link ResultSet#FETCH_FORWARD}. - *
- * - * @see java.sql.ResultSet#absolute(int) - */ - @Override - public boolean absolute( int row ) throws SQLException { - notClosed(); - forwardOnly(); - - return false; - } - - /** - * {@inheritDoc} - *- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports - * {@link ResultSet#FETCH_FORWARD}. - *
- * - * @see java.sql.ResultSet#afterLast() - */ - @Override - public void afterLast() throws SQLException { - notClosed(); - forwardOnly(); - } - - /** - * {@inheritDoc} - *- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports - * {@link ResultSet#FETCH_FORWARD}. - *
- * - * @see java.sql.ResultSet#beforeFirst() - */ - @Override - public void beforeFirst() throws SQLException { - notClosed(); - forwardOnly(); - - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#cancelRowUpdates() - */ - @Override - public void cancelRowUpdates() throws SQLException { - notClosed(); - noUpdates(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#clearWarnings() - */ - @Override - public void clearWarnings() throws SQLException { - notClosed(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#deleteRow() - */ - @Override - public void deleteRow() throws SQLException { - notClosed(); - noUpdates(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#findColumn(java.lang.String) - */ - @Override - public int findColumn( String columnLabel ) throws SQLException { - notClosed(); - final Integer result = columnLabel != null ? columnIndexesByName.get(columnLabel) : null; - - if (result == null) { - this.itemNotFoundUsingColunName(columnLabel); - } - assert result != null; - return result.intValue(); - } - - private String findColumn( int columnIndex ) throws SQLException { - if (columnIndex > 0 && columnIndex < this.columnIDs.length) { - return columnIDs[columnIndex]; - } - - throw new SQLException(JdbcI18n.invalidColumnIndex.text(new Object[] {columnIndex, this.columnIDs.length})); - } - - /** - * {@inheritDoc} - *- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports - * {@link ResultSet#FETCH_FORWARD}. - *
- * - * @see java.sql.ResultSet#first() - */ - @Override - public boolean first() throws SQLException { - notClosed(); - forwardOnly(); - - return false; - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getRow() - */ - @Override - public int getRow() throws SQLException { - notClosed(); - return (int)this.rowIter.getPosition(); - } - - /** - * {@inheritDoc} - *- * This method will always throw {@link SQLFeatureNotSupportedException} - *
- * - * @see java.sql.ResultSet#getRowId(int) - */ - @Override - public RowId getRowId( final int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getRowId(java.lang.String) - */ - @Override - public RowId getRowId( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getCursorName() - */ - @Override - public String getCursorName() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getFetchSize() - */ - @Override - public int getFetchSize() throws SQLException { - notClosed(); - return statement.getFetchSize(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getArray(int) - */ - @Override - public Array getArray( int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getArray(java.lang.String) - */ - @Override - public Array getArray( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getAsciiStream(int) - */ - @Override - public InputStream getAsciiStream( int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getAsciiStream(java.lang.String) - */ - @Override - public InputStream getAsciiStream( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBigDecimal(int) - */ - @Override - public BigDecimal getBigDecimal( int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBigDecimal(java.lang.String) - */ - @Override - public BigDecimal getBigDecimal( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBigDecimal(int, int) - */ - @Override - public BigDecimal getBigDecimal( int columnIndex, - int scale ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBigDecimal(java.lang.String, int) - */ - @Override - public BigDecimal getBigDecimal( String columnLabel, - int scale ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBinaryStream(int) - */ - @Override - public InputStream getBinaryStream( int columnIndex ) throws SQLException { - return getBinaryStream(findColumn(columnIndex)); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBinaryStream(java.lang.String) - */ - @Override - public InputStream getBinaryStream( String columnLabel ) throws SQLException { - Object o = getValueReturn(columnLabel, PropertyType.BINARY); - if (o != null) { - return (InputStream) o; - } - return null; - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBlob(int) - */ - @Override - public Blob getBlob( int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBlob(java.lang.String) - */ - @Override - public Blob getBlob( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBoolean(int) - */ - @Override - public boolean getBoolean( int columnIndex ) throws SQLException { - return getBoolean(findColumn(columnIndex)); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBoolean(java.lang.String) - */ - @Override - public boolean getBoolean( String columnLabel ) throws SQLException { - - Object o = getValueReturn(columnLabel, PropertyType.BOOLEAN); - if (o != null) { - return ((Boolean) o).booleanValue(); - } - return Boolean.FALSE.booleanValue(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getByte(int) - */ - @Override - public byte getByte( int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getByte(java.lang.String) - */ - @Override - public byte getByte( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBytes(int) - */ - @Override - public byte[] getBytes( int columnIndex ) throws SQLException { - return getBytes(findColumn(columnIndex)); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getBytes(java.lang.String) - */ - @Override - public byte[] getBytes( String columnLabel ) throws SQLException { - notClosed(); - isRowSet(); - - this.currentValue = null; - try { - Value value = row.getValue(columnLabel); - byte[] rtnbytes = convertToByteArray(value); - this.currentValue = rtnbytes; - return rtnbytes; - } catch (PathNotFoundException pnfe) { - // do nothing, return null - } catch (ItemNotFoundException e) { - itemNotFoundUsingColunName(columnLabel); - } catch (RepositoryException e) { - throw new SQLException(e.getLocalizedMessage(), e); - } - return null; - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getCharacterStream(int) - */ - @Override - public Reader getCharacterStream( int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getCharacterStream(java.lang.String) - */ - @Override - public Reader getCharacterStream( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getClob(int) - */ - @Override - public Clob getClob( int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getClob(java.lang.String) - */ - @Override - public Clob getClob( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getConcurrency() - */ - @Override - public int getConcurrency() throws SQLException { - notClosed(); - return 0; - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getDate(int) - */ - @Override - public Date getDate( int columnIndex ) throws SQLException { - return getDate(findColumn(columnIndex)); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getDate(java.lang.String) - */ - @Override - public Date getDate( String columnLabel ) throws SQLException { - Calendar calv = (Calendar)getValueReturn(columnLabel, PropertyType.DATE); - if (calv == null) return null; - - return TimestampWithTimezone.createDate(calv.getTime()); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getDate(int, java.util.Calendar) - */ - @Override - public Date getDate( int columnIndex, - Calendar cal ) throws SQLException { - return getDate(findColumn(columnIndex), cal); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getDate(java.lang.String, java.util.Calendar) - */ - @Override - public Date getDate( String columnLabel, - Calendar cal ) throws SQLException { - - Calendar actual = (Calendar)getValueReturn(columnLabel, PropertyType.DATE); - - if (actual == null) return null; - - java.util.Date actualDate = actual.getTime(); - java.util.TimeZone actualTz = actual.getTimeZone(); - - // if cal is null, it will be supplied in TimestampWithTimezone - return TimestampWithTimezone.createDate(actualDate,actualTz,cal); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getDouble(int) - */ - @Override - public double getDouble( int columnIndex ) throws SQLException { - return getDouble(findColumn(columnIndex)); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getDouble(java.lang.String) - */ - @Override - public double getDouble( String columnLabel ) throws SQLException { - Object o = getValueReturn(columnLabel, PropertyType.DOUBLE); - if (o != null) { - return ((Double) o).doubleValue(); - } - return 0; - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getFloat(int) - */ - @Override - public float getFloat( int columnIndex ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - * - * @see java.sql.ResultSet#getFloat(java.lang.String) - */ - @Override - public float getFloat( String columnLabel ) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - /** - * {@inheritDoc} - *
- * According to 1.6 javadocs, holdability should be set to either {@link ResultSet#CLOSE_CURSORS_AT_COMMIT} or
- * {@link ResultSet#HOLD_CURSORS_OVER_COMMIT}. However, JDBC 4.0 spec says the default holdability is implementation defined.
- * Therefore, the default value will be 0.
- *
- * @see java.sql.ResultSet#getHoldability()
- */
- @Override
- public int getHoldability() throws SQLException {
- notClosed();
- return 0;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getInt(int)
- */
- @Override
- public int getInt( int columnIndex ) throws SQLException {
- return getInt(findColumn(columnIndex));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getInt(java.lang.String)
- */
- @Override
- public int getInt( String columnLabel ) throws SQLException {
- notClosed();
- return (int)getLong(columnLabel);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getLong(int)
- */
- @Override
- public long getLong( int columnIndex ) throws SQLException {
- return getLong(findColumn(columnIndex));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getLong(java.lang.String)
- */
- @Override
- public long getLong( String columnLabel ) throws SQLException {
- Object o = getValueReturn(columnLabel, PropertyType.LONG);
- if (o != null) {
- return ( (Long) o).longValue();
- }
- return 0L;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getNCharacterStream(int)
- */
- @Override
- public Reader getNCharacterStream( int columnIndex ) throws SQLException {
- throw new SQLFeatureNotSupportedException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getNCharacterStream(java.lang.String)
- */
- @Override
- public Reader getNCharacterStream( String columnLabel ) throws SQLException {
- throw new SQLFeatureNotSupportedException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getNClob(int)
- */
- @Override
- public NClob getNClob( int columnIndex ) throws SQLException {
- throw new SQLFeatureNotSupportedException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getNClob(java.lang.String)
- */
- @Override
- public NClob getNClob( String columnLabel ) throws SQLException {
- throw new SQLFeatureNotSupportedException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getNString(int)
- */
- @Override
- public String getNString( int columnIndex ) throws SQLException {
- throw new SQLFeatureNotSupportedException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getNString(java.lang.String)
- * @throws SQLFeatureNotSupportedException();
- */
- @Override
- public String getNString( String columnLabel ) throws SQLException {
- throw new SQLFeatureNotSupportedException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getObject(int)
- */
- @Override
- public Object getObject( int columnIndex ) throws SQLException {
- return getObject(findColumn(columnIndex));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getObject(java.lang.String)
- */
- @Override
- public Object getObject( String columnLabel ) throws SQLException {
- return getColumnTranslatedToJDBC(columnLabel);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getObject(int, java.util.Map)
- */
- @Override
- public Object getObject( int columnIndex,
- Map
- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports
- * {@link ResultSet#FETCH_FORWARD}.
- *
- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports
- * {@link ResultSet#FETCH_FORWARD}.
- *
- * This method, when cursor position is after the last row, will return
- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports
- * {@link ResultSet#FETCH_FORWARD}.
- *
- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports
- * {@link ResultSet#FETCH_FORWARD}.
- *
- * This method, when called on an open result set, always throws {@link SQLException} because this driver only supports
- * {@link ResultSet#FETCH_FORWARD}.
- *
- * This method always returns false since this JDBC driver does not support any updates.
- *
- * This method always returns false since this JDBC driver does not support any updates.
- *
- * This method always returns false since this JDBC driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * This method, when called on an open result set, always throws {@link SQLFeatureNotSupportedException} since this JDBC
- * driver does not support any updates.
- *
- * All columns come from the same repository (i.e., catalog).
- *
- * This method returns the nominal display size based upon the column's type. Therefore, the value may not reflect the optimal
- * display size for any given value.
- *
- * This method always returns the nominal display size for the type.
- *
- * This method returns the number of digits behind the decimal point, which is assumed to be 3 if the type is
- * {@link PropertyType#DOUBLE} or 0 otherwise.
- *
- * This method always returns the workspace name.
- *
- * This method always returns false, since this JCR property types don't represent auto-incremented values.
- *
- * This method always returns false, since no JCR property types (directly) represent currency.
- *
- * This method always returns false, since this JDBC driver does not support writes.
- *
- * Even though the value may be writable in the JCR repository, this JDBC driver does not support writes. Therefore, this
- * method always returns true.
- *
- * In JCR-SQL2, every property can be used in a WHERE clause. Therefore, this method always returns true.
- *
- * This method returns true if the column is a {@link PropertyType#DOUBLE}, {@link PropertyType#LONG} or
- * {@link PropertyType#DATE}.
- *
- * Even though the value may be writable in the JCR repository, this JDBC driver does not support writes. Therefore, this
- * method always returns false.
- *
- * This driver doesn't have a way to set the fetch size, so this method always returns 0.
- *
- * This driver doesn't have a way to set the fetch size, so this method is ignored and does nothing.
- *
- * This driver does not support limiting the field size, and always returns 0.
- *
- * This method returns 0 since there is currently no timeout with JCR 1.0 or JCR 2.0.
- *
- * ModeShape does support
- * ModeShape does support
- * ModeShape does support
- * ModeShape uses arithmetic operations in criteria, and in the current implementation if one operand is null then the
- * operations returns the other. Therefore, 'null + X = X', so this method returns
- * ModeShape definitely uses sort order. Therefore, this method always returns
- * ModeShape definitely uses sort order. Therefore, this method always returns
- * ModeShape sorts null values to be lower than non-null values. Therefore, this method returns
- * ModeShape sorts null values to be lower than non-null values. Therefore, this method returns This class contains constants indicating names of the columns in the
- * result sets returned by methods on JcrMetaData. Each inner class represents
- * a particular method and the class attributes give the names of the columns on
- * methods ResultSet. This class provides constants indicating positions of columns in the
- * The constants in the inner classes could include column positions for columns
- * that are hardcoded, columns positions of some columns on server's
- * Each of the inner classes have a constant All the column positions are one based.
- */
-
-public interface JDBCColumnPositions {
-
- /**
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getIndexInfo method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getCrossReferences method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getProcedures method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class also has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This class contains constants representing column positions on ResultSet
- * returned by getColumns method on DatabaseMetaData. The class also has constants
- * for columns whose values are to be hardcoded in MMDatabaseMetaData object.
- * This is a helper class used to obtain SQL type information for java types.
- * The SQL type information is obtained from java.sql.Types class. The integers and
- * strings returned by methods in this class are based on constants in java.sql.Types.
- */
-
-public final class JDBCSQLTypeInfo {
-
-
- // Prevent instantiation
- private JDBCSQLTypeInfo() {}
-
- public static final class DefaultDataTypes {
- public static final String STRING = "string"; //$NON-NLS-1$
- public static final String BOOLEAN = "boolean"; //$NON-NLS-1$
- public static final String BYTE = "byte"; //$NON-NLS-1$
- public static final String SHORT = "short"; //$NON-NLS-1$
- public static final String CHAR = "char"; //$NON-NLS-1$
- public static final String INTEGER = "integer"; //$NON-NLS-1$
- public static final String LONG = "long"; //$NON-NLS-1$
- public static final String BIG_INTEGER = "biginteger"; //$NON-NLS-1$
- public static final String FLOAT = "float"; //$NON-NLS-1$
- public static final String DOUBLE = "double"; //$NON-NLS-1$
- public static final String BIG_DECIMAL = "bigdecimal"; //$NON-NLS-1$
- public static final String DATE = "date"; //$NON-NLS-1$
- public static final String TIME = "time"; //$NON-NLS-1$
- public static final String TIMESTAMP = "timestamp"; //$NON-NLS-1$
- public static final String OBJECT = "object"; //$NON-NLS-1$
- public static final String NULL = "null"; //$NON-NLS-1$
- public static final String BLOB = "blob"; //$NON-NLS-1$
- public static final String CLOB = "clob"; //$NON-NLS-1$
- public static final String XML = "xml"; //$NON-NLS-1$
- }
-
- //java class names
- public static final class DefaultDataClasses {
- public static final Classvalue
based on type
- *
- * @param value
- * @param type indicates {@link PropertyType} used to derive return object type
- * @return Object
- * @throws SQLException
- */
- private Object getValueObject( Value value,
- int type ) throws SQLException {
- if (value == null) return null;
-
- try {
- switch (type) {
-
- case PropertyType.STRING:
- return value.getString();
- case PropertyType.BOOLEAN:
- return value.getBoolean();
- case PropertyType.DATE:
- // return new java.sql.Date(value.getDate().getTime().getTime());
- return value.getDate();
- case PropertyType.DOUBLE:
- return value.getDouble();
- case PropertyType.LONG:
- return value.getLong();
- case PropertyType.BINARY:
- return value.getBinary().getStream();
- }
-
- } catch (ValueFormatException ve) {
- throw new SQLException(ve.getLocalizedMessage(), ve);
- } catch (IllegalStateException ie) {
- throw new SQLException(ie.getLocalizedMessage(), ie);
- } catch (RepositoryException e) {
- throw new SQLException(e.getLocalizedMessage(), e);
- }
- return value.toString();
- }
-
- /**
- * This method transforms a {@link Value} into a JDBC type based on {@link JcrType} mappings
- *
- * @param columnName
- * @return Object
- * @throws SQLException
- */
- private Object getColumnTranslatedToJDBC( String columnName ) throws SQLException {
- notClosed();
- isRowSet();
-
- Value value = null;
- this.currentValue = null;
-
- try {
- value = row.getValue(columnName);
- } catch (javax.jcr.PathNotFoundException pnf) {
- // do nothing
- } catch (RepositoryException e) {
- throw new SQLException(e.getLocalizedMessage(), e);
- }
-
- if (value == null) return null;
-
- this.currentValue = JcrType.translateValueToJDBC(value);
- return this.currentValue;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#getWarnings()
- */
- @Override
- public SQLWarning getWarnings() /*throws SQLException*/{
- return null;
- }
-
- protected boolean hasNext() {
- return rowIter.hasNext();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#insertRow()
- */
- @Override
- public void insertRow() throws SQLException {
- this.notClosed();
- this.noUpdates();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#isAfterLast()
- */
- @Override
- public boolean isAfterLast() throws SQLException {
- this.notClosed();
- if (this.row == null && !this.rowIter.hasNext() && this.rowIter.getPosition() == this.rowIter.getSize()) {
- return true;
- }
- return false;
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#isBeforeFirst()
- */
- @Override
- public boolean isBeforeFirst() throws SQLException {
- this.notClosed();
- if (this.rowIter.getPosition() == 0) {
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#isFirst()
- */
- @Override
- public boolean isFirst() throws SQLException {
- this.notClosed();
- if (this.rowIter.getPosition() == 1) {
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.sql.ResultSet#isLast()
- */
- @Override
- public boolean isLast() throws SQLException {
- this.notClosed();
-
- if (this.row != null && !this.rowIter.hasNext() && this.rowIter.getPosition() == this.rowIter.getSize()) {
- return true;
- }
- return false;
- }
-
- protected final void isRowSet() throws SQLException {
- if (this.row != null) return;
-
- throw new SQLException(JdbcI18n.currentRowNotSet.text());
- }
-
- /**
- * {@inheritDoc}
- * false
- * org.modeshape.jdbc*
packages.
*/
public final class JdbcI18n {
-
- public static I18n i18nClassInterface;
- public static I18n i18nClassNotPublic;
- public static I18n i18nFieldFinal;
- public static I18n i18nFieldInvalidType;
- public static I18n i18nFieldNotPublic;
- public static I18n i18nFieldNotStatic;
- public static I18n i18nLocalizationFileNotFound;
- public static I18n i18nLocalizationProblems;
- public static I18n i18nPropertyDuplicate;
- public static I18n i18nPropertyMissing;
- public static I18n i18nPropertyUnused;
- public static I18n i18nRequiredToSuppliedParameterMismatch;
public static I18n driverName;
public static I18n driverVendor;
public static I18n driverVendorUrl;
public static I18n driverVersion;
-
- public static I18n driverErrorRegistering;
-
- /*
- * ConnectionInfo related text info
- */
- public static I18n usernamePropertyDescription;
- public static I18n passwordPropertyDescription;
- public static I18n workspaceNamePropertyDescription;
- public static I18n repositoryNamePropertyDescription;
- public static I18n urlPropertyDescription;
- public static I18n urlPropertyName;
- public static I18n usernamePropertyName;
- public static I18n passwordPropertyName;
- public static I18n workspaceNamePropertyName;
- public static I18n repositoryNamePropertyName;
-
-
- public static I18n invalidUrl;
- public static I18n invalidUrlPrefix;
- public static I18n failedToReadPropertiesFromManifest;
- public static I18n unableToFindNamedRepository;
- public static I18n noRepositoryNamesFound;
- public static I18n argumentMayNotBeNegative;
- public static I18n argumentMayNotBeNull;
- public static I18n requiredToSuppliedParameterMismatch;
- public static I18n connectionIsClosed;
- public static I18n statementIsClosed;
- public static I18n resultSetIsClosed;
- public static I18n resultSetIsForwardOnly;
- public static I18n noSuchColumn;
- public static I18n updatesNotSupported;
- public static I18n timeoutMayNotBeNegative;
- public static I18n classDoesNotImplementInterface;
- public static I18n invalidClientInfo;
- public static I18n invalidArgument;
- public static I18n invalidColumnIndex;
- public static I18n currentRowNotSet;
- public static I18n noJcrTypeMapped;
- public static I18n unableToGetNodeTypes;
- public static I18n noNodeTypesReturned;
- public static I18n unableToGetNodeType;
- public static I18n noSuchNodeType;
-
-
- public static I18n repositoryNameInUse;
-
- /*
- * JNDI connection option related text info
- */
- public static I18n objectInJndiMustBeRepositoryOrRepositories;
- public static I18n unableToGetJndiContext;
- public static I18n urlMustContainJndiNameOfRepositoryOrRepositoriesObject;
- public static I18n unableToFindObjectInJndi;
- public static I18n objectInJndiIsRepositories;
-
- /**
- * HTTP connection option related text info
- */
+ public static I18n driverErrorRegistering;
-
- /*
- * File connection option relatd text info
- */
- public static I18n configurationFileNotSpecified;
-
-
-
static {
try {
I18n.initialize(JdbcI18n.class);
Index: utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/ModeShapeMetaData.java
deleted file mode 100644
===================================================================
--- utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/ModeShapeMetaData.java (revision 2552)
+++ /dev/null (working copy)
@@ -1,144 +0,0 @@
-/*
- * ModeShape (http://www.modeshape.org)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * ModeShape is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.modeshape.jdbc;
-
-
-/**
- * Specialized implementation for ModeShape-specific features.
- */
-public class ModeShapeMetaData extends JcrMetaData {
-
- public ModeShapeMetaData( JcrConnection connection) {
- super(connection);
- }
-
- /**
- * {@inheritDoc}
- * FULL OUTER JOIN
, so this method returns true when this driver connects to a ModeShape
- * JCR repository.
- * UNION
, so this method returns true when this driver connects to a ModeShape JCR
- * repository.
- * UNION ALL
, so this method returns true when this driver connects to a ModeShape JCR
- * repository.
- * false
.
- * false
.
- * false
.
- * false
.
- * true
.
- * query
based on the specified Jcr language.
- *
- * @param query is the sql query to execute
- * @param language is the JCR language the query
should be executed based on.
- * @return QueryResult is the JCR query result
- * @throws RepositoryException
- */
- QueryResult execute(String query, String language) throws RepositoryException;
-
-
- /**
- * Call to create the connection based on the implementation of this interface.
- * @return Connection
- * @throws SQLException
- *
- * @see java.sql.Driver#connect(String, java.util.Properties)
- */
- Connection createConnection() throws SQLException;
-
- /**
- *
- * @see java.sql.Connection#commit()
- *
- * @throws RepositoryException
- */
-
- void commit() throws RepositoryException;
-
- /**
- *
- * @see java.sql.Connection#rollback()
- *
- * @throws RepositoryException
- */
- void rollback() throws RepositoryException;
-
- /**
- *
- * @see java.sql.Connection#isValid(int)
- *
- * @param timeout
- * @return boolean indicating if timeout is valid
- * @throws RepositoryException
-
- */
- boolean isValid( int timeout ) throws RepositoryException ;
-
-
- /**
- *
- * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
- *
- * @param iface
- * @return boolean
- */
- boolean isWrapperFor( Class> iface ) ;
-
- /**
- *
- * @see java.sql.Wrapper#unwrap(java.lang.Class)
- *
- * @param iface
- * @param descriptorKey
- * @param descriptorKey
- * @return String descriptor value
- */
- String getDescriptor(String descriptorKey);
-
-}
Index: utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/delegate/RepositoryDelegateFactory.java
deleted file mode 100644
===================================================================
--- utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/delegate/RepositoryDelegateFactory.java (revision 2552)
+++ /dev/null (working copy)
@@ -1,101 +0,0 @@
-/*
- * ModeShape (http://www.modeshape.org)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * ModeShape is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.modeshape.jdbc.delegate;
-
-import java.sql.SQLException;
-import java.util.Properties;
-import org.modeshape.jdbc.JcrDriver;
-import org.modeshape.jdbc.JdbcI18n;
-import org.modeshape.jdbc.JcrDriver.JcrContextFactory;
-
-/**
- * The RepositoryDelegateFactory is used to create the required type of {@link RepositoryDelegate} based upon the url
- * provided. The url must be prefixed by either {@value JcrDriver#JNDI_URL_PREFIX} or {@value JcrDriver#HTTP_URL_PREFIX}.
- */
-public class RepositoryDelegateFactory {
-
- private static final int JNDI_URL_OPTION = 1;
- private static final int HTTP_URL_OPTION = 2;
-
- public static RepositoryDelegate createRepositoryDelegate( String url,
- Properties info,
- JcrContextFactory contextFactory ) throws SQLException {
- if (!acceptUrl(url)) {
- throw new SQLException(JdbcI18n.invalidUrlPrefix.text(JcrDriver.JNDI_URL_PREFIX, JcrDriver.HTTP_URL_PREFIX));
- }
- RepositoryDelegate jcri = create(url, info, contextFactory);
-
- // TODO: an exception should be thrown if a property info is not available.
- // the getPropertyInfos on the driver should return what the driver
- // needs in order to connect
- // DriverPropertyInfo[] infos = jcri.getConnectionInfo().getPropertyInfos();
- // if (infos != null && infos.length > 0) {
- // StringBuilder missing = new StringBuilder();
- // for (int i = 0; i < infos.length; i++) {
- // missing.append(infos[i].description);
- // if (i + 1 < infos.length) {
- // missing.append(",");
- // }
- // }
- //
- // throw new SQLException(JdbcI18n.invalidUrl.text(missing.toString()));
- // }
- return jcri;
- }
-
- public static boolean acceptUrl( String url ) {
- return (getUrlOption(url) > 0 ? true : false);
- }
-
- private static int getUrlOption( String url ) {
- if (url == null || url.trim().length() == 0) return -1;
- String trimmedUrl = url.trim();
- if (trimmedUrl.startsWith(JcrDriver.JNDI_URL_PREFIX) && trimmedUrl.length() > JcrDriver.JNDI_URL_PREFIX.length()) {
- // This fits the pattern so far ...
- return JNDI_URL_OPTION;
- }
- if (trimmedUrl.startsWith(JcrDriver.HTTP_URL_PREFIX) && trimmedUrl.length() > JcrDriver.HTTP_URL_PREFIX.length()) {
- // This fits the pattern so far ...
- return HTTP_URL_OPTION;
- }
-
- return -1;
- }
-
- private static RepositoryDelegate create( String url,
- Properties info,
- JcrContextFactory contextFactory ) {
-
- switch (getUrlOption(url)) {
- case JNDI_URL_OPTION:
- return new LocalRepositoryDelegate(url, info, contextFactory);
-
- case HTTP_URL_OPTION:
- return new HttpRepositoryDelegate(url, info, contextFactory);
-
- default:
- return null;
- }
- }
-}
Index: utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/metadata/JDBCColumnNames.java
deleted file mode 100644
===================================================================
--- utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/metadata/JDBCColumnNames.java (revision 2552)
+++ /dev/null (working copy)
@@ -1,380 +0,0 @@
-/*
- * ModeShape (http://www.modeshape.org)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * ModeShape is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.modeshape.jdbc.metadata;
-
-/* ResultSets
returned by methods on MMDatabaseMetaData
- * object. The inner classes represent the methods while attributes represent the
- * column positions. The name of the constant explains the column content.Results
object.MAX_COLUMNS
that
- * represents the number of columns to be read from the server's Results
- * object.MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- * JAVA_CLASS
is the column position for element data type on
- * server's Results object.
- */
- interface SCHEMAS {
- /** Number of columns to be read from results returned getElements method. */
- static final int MAX_COLUMNS = 2;
- static final int TABLE_CATALOG = 2;
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- * JAVA_CLASS
is the column position for element data type on
- * server's Results object.
- */
- interface CATALOGS {
-
- /** Number of columns to be read from results returned getElements method. */
- static final int MAX_COLUMNS = 1;
- }
-
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- * JAVA_CLASS
is the column position for element data type on
- * server's Results object.
- */
- interface COLUMNS {
-
- /** Number of columns to be read from results returned getElements method. */
- static final int MAX_COLUMNS = 22;
-
- /** Position of column that contains catalog name in which the table for the column is present. */
- static final int TABLE_CAT = 1;
-
- static final int TABLE_SCHEM = 2;
-
- static final int TABLE_NAME = 3;
-
- static final int COLUMN_NAME = 4;
-
- /** Position of column that contains SQL type from java.sql.Types for column's data type. */
- static final int DATA_TYPE = 5;
-
- /** Position of column that contains local type name used by the data source. */
- static final int TYPE_NAME = 6;
-
- static final int COLUMN_SIZE = 7;
-
- /** Position of column that is not used will contain nulls */
- static final int BUFFER_LENGTH = 8;
-
- static final int DECIMAL_DIGITS = 9;
-
- static final int NUM_PREC_RADIX = 10;
-
- /** Position of column that has an int value indicating nullablity */
- static final int NULLABLE = 11;
-
- /** Position of column containing explanatory notes. */
- static final int REMARKS = 12;
-
- static final int COLUMN_DEF = 13;
-
- /** Position of column that not used will contain nulls */
- static final int SQL_DATA_TYPE = 14;
-
- /** Position of column that not used will contain nulls */
- static final int SQL_DATETIME_SUB = 15;
-
- static final int CHAR_OCTET_LENGTH = 16;
-
- static final int ORDINAL_POSITION = 17;
-
- /** Position of column that has an String value indicating nullablity */
- static final int IS_NULLABLE = 18;
-
- static final int SCOPE_CATALOG = 19;
-
- static final int SCOPE_SCHEMA = 20;
-
- static final int SCOPE_TABLE = 21;
-
- static final int SOURCE_DATA_TYPE = 22;
-
- static final int IS_AUTOINCREMENT = 23;
-
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- * JAVA_CLASS
is the column position for element data type on
- * server's Results object.
- */
- interface TABLES {
-
- /** Number of columns to be read from results returned getTables method. */
- static final int MAX_COLUMNS = 10;
-
- /** Position of column that contains catalog name in which the table is present. */
- static final int TABLE_CAT = 1;
- static final int TYPE_CAT = 6;
- static final int TYPE_SCHEM = 7;
- static final int TYPE_NAME = 8;
- static final int SELF_REFERENCING_COL_NAME = 9;
- static final int REF_GENERATION = 10;
- static final int ISPHYSICAL = 11;
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- * JAVA_CLASS
is the column position for element data type on
- * server's Results object.
- */
- interface TYPE_INFO {
-
- /** Number of columns to be read from results returned getElements method. */
- static final int MAX_COLUMNS = 18;
-
- /** Position of column that contains local type name used by the data source. */
- static final int TYPE_NAME = 1;
-
- /** Position of column that contains SQL type from java.sql.Types for column's data type. */
- static final int DATA_TYPE = 2;
-
- static final int PRECISION = 3;
- /** Position of column that contains prefix used to quote a literal. */
- static final int LITERAL_PREFIX = 4;
-
- /** Position of column that contains suffix used to quote a literal. */
- static final int LITERAL_SUFFIX = 5;
-
- /** Position of column that contains params used in creating the type. */
- static final int CREATE_PARAMS = 6;
-
- /** Position of column that contains the nullable value. */
- static final int NULLABLE = 7;
-
- static final int CASE_SENSITIVE = 8;
-
- /** Position of column that contains the searchable value. */
- static final int SEARCHABLE = 9;
-
- /** Position of column that contains the unsigned value. */
- static final int UNSIGNED_ATTRIBUTE = 10;
-
- static final int FIXED_PREC_SCALE = 11;
-
- static final int AUTO_INCREMENT = 12;
-
- /** Position of column that contains local type name used by the data source. */
- static final int LOCAL_TYPE_NAME = 13;
-
- /** Position of column that contains the min scale value. */
- static final int MINIMUM_SCALE = 14;
-
- /** Position of column that contains the max scale value. */
- static final int MAXIMUM_SCALE = 15;
-
- /** Position of column that not used will contain nulls */
- static final int SQL_DATA_TYPE = 16;
-
- /** Position of column that not used will contain nulls */
- static final int SQL_DATETIME_SUB = 17;
-
- static final int NUM_PREC_RADIX = 18;
-
- /** Position of column in server's results containing name of the datatype.*/
- static final int NAME = 19;
-
- /** Position of column in server's results containing isSigned value.*/
- static final int IS_SIGNED = 20;
-
- /** Position of column in server's results containing nullType name.*/
- static final int NULL_TYPE_NAME = 21;
-
- /** Position of column in server's results containing search type name.*/
- static final int SEARCH_TYPE_NAME = 22;
- }
-
- /**
- * This class contains constants representing column positions on ResultSet
- * returned by getUDTS method on DatabaseMetaData. These constant values
- * are be used to hardcode the column values used in constructin the ResultSet obj.
- */
- interface UDTS {
-
- /** Number of columns to be read from results returned getUserDefinedTypes method. */
- static final int MAX_COLUMNS = 7;
-
- // name of the column containing table or Groups name in which UDTS are present.
- static final int TABLE_NAME = 3;
-
- // name of the column containing catalog or Virtual database name.
- static final int TYPE_CAT = 1;
-
- // name of the column containing schema or Virtual database version.
- static final int TYPE_SCHEM = 2;
-
- // name of the column containing name of type name column.
- static final int TYPE_NAME = 9;
-
- // name of the column containing class name column.
- static final int CLASS_NAME = 4;
-
- // name of the column containing name of sql datatype code column
- static final int DATA_TYPE = 5;
-
- // name of the column containing comments column
- static final int REMARKS = 6;
-
- static final int BASE_TYPE = 7;
- /** Position of column in server's results containing java class name.*/
- static final int JAVA_CLASS = 8;
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from the query against System.KeyElements table.MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- * JAVA_CLASS
is the column position for element data type on
- * server's Results object.
- */
- interface PRIMARY_KEYS {
-
- /** Number of columns to be read from results returned by getPrimaryKeys. */
- static final int MAX_COLUMNS = 6;
-
- /** Position of column that contains catalog name of the primaryTable. */
- static final int TABLE_CAT = 1;
- static final int TABLE_SCHEM = 2;
- static final int TABLE_NAME = 3;
- static final int COLUMN_NAME = 4;
- static final int KEY_SEQ = 5;
- static final int PK_NAME = 6;
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getCrossReferences method on server's Metadata object
.
- */
- interface REFERENCE_KEYS {
-
- /** Number of columns to be read from results returned any of the 3 methods. */
- static final int MAX_COLUMNS = 14;
-
- /** Position of column that contains catalog name of the primaryTable. */
- static final int PKTABLE_CAT = 1;
-
- /** Position of column that contains scheam name of the primaryTable. */
- static final int PKTABLE_SCHEM = 2;
-
- static final int PKTABLE_NAME = 3;
-
- static final int PKCOLUMN_NAME = 4;
-
- /** Position of column that contains catalog name of the foreignTable. */
- static final int FKTABLE_CAT = 5;
-
- /** Position of column that contains schema name of the foreignTable. */
- static final int FKTABLE_SCHEM = 6;
-
- static final int FKTABLE_NAME = 7;
-
- static final int FKCOLUMN_NAME = 8;
-
- static final int KEY_SEQ = 9;
-
- /** Position of column that determines how forein key changes if PK is updated. */
- static final int UPDATE_RULE = 10;
-
- /** Position of column that determines how forein key changes if PK is deleted. */
- static final int DELETE_RULE = 11;
-
- static final int FK_NAME = 12;
-
- static final int PK_NAME = 13;
-
- /** Position of column that determines if forein key constraints can be deffered until commit. */
- static final int DEFERRABILITY = 14;
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- * JAVA_CLASS
is the column position for element data type on
- * server's Results object.
- */
- interface PROCEDURES {
-
- /** Number of columns to be read from results returned getCrossReferences method. */
- static final int MAX_COLUMNS = 9;
-
- /** Position of column that contains catalog name of the procedure. */
- static final int PROCEDURE_CAT = 1;
- static final int PROCEDURE_SCHEM = 2;
- static final int PROCEDURE_NAME = 3;
-
- /** Position of column the is reserved for future use. */
- static final int RESERVED_1 = 4;
-
- /** Position of column the is reserved for future use. */
- static final int RESERVED_2 = 5;
-
- /** Position of column the is reserved for future use. */
- static final int RESERVED_3 = 6;
-
- static final int REMARKS = 7;
-
- /** Position of column Procedure type. */
- static final int PROCEDURE_TYPE = 8;
-
- static final int SPECIFIC_NAME = 9;
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- * JAVA_CLASS
is the column position for element data type on
- * server's Results object.
- */
- interface PROCEDURE_COLUMNS {
-
- /** Number of columns to be read from results returned getProcedureColumns method. */
- static final int MAX_COLUMNS = 20;
-
- /** Position of column that contains catalog name of the procedure. */
- static final int PROCEDURE_CAT = 1;
-
- static final int PROCEDURE_SCHEM = 2;
- static final int PROCEDURE_NAME = 3;
- static final int COLUMN_NAME = 4;
-
- /** Position of the column containing column or element type. */
- static final int COLUMN_TYPE = 5;
-
- /** Position of column that contains SQL type from java.sql.Types for column's data type. */
- static final int DATA_TYPE = 6;
-
- /** Position of column that contains local type name used by the data source. */
- static final int TYPE_NAME = 7;
-
- static final int PRECISION = 8;
- static final int LENGTH = 9;
- static final int SCALE = 10;
- static final int RADIX = 11;
-
- /** Position of column that contains the nullable value. */
- static final int NULLABLE = 12;
-
- /** Position of column that contains comments. */
- static final int REMARKS = 13;
- static final int COLUMN_DEF = 14;
-
- static final int SQL_DATA_TYPE = 15;
- static final int SQL_DATETIME_SUB = 16;
- static final int CHAR_OCTET_LENGTH = 17;
-
- static final int ORDINAL_POSITION = 18;
-
- static final int IS_NULLABLE = 19;
-
- static final int SPECIFIC_NAME = 20;
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- */
- interface TABLE_PRIVILEGES {
-
- /** Number of columns to be read from results returned getGroupEntitlements method. */
- static final int MAX_COLUMNS = 6;
-
- /** Position of VirtualDatabaseName column in server's results object returned by
- getGroupEntitlements method in User API */
- static final int VIRTUAL_DATABASE_NAME = 0;
-
- /** Position of VirtualDatabaseVersion column in server's results object returned by
- getElementEntitlements method in User API */
- static final int VIRTUAL_DATABASE_VERSION = 1;
-
- /** Position of GroupName column in server's results object returned by
- getGroupEntitlements method in User API */
- static final int GROUP_NAME = 2;
-
- /** Position of Grantor column in server's results object returned by
- getGroupEntitlements method in User API */
- static final int GRANTOR = 3;
-
- /** Position of Grantee column in server's results object returned by
- getGroupEntitlements method in User API */
- static final int GRANTEE = 4;
-
- /** Position of Permission column in server's results object returned by
- getGroupEntitlements method in User API */
- static final int PERMISSION = 5;
-
- /** Position of the column containing catalog name info. */
- static final int TABLE_CAT = 0;
-
- /** Position of the column containing privilage grantable info. */
- static final int IS_GRANTABLE = 6;
- }
-
- /**
- * MAX_COLUMNS
is the number of columns to be read from server's
- * results from getElements method on Metadata object
.
- */
- interface COLUMN_PRIVILEGES {
-
- /** Number of columns to be read from results returned getElementEntitlements method. */
- static final int MAX_COLUMNS = 7;
-
- /** Position of VirtualDatabaseName column in server's results object returned by
- getElementEntitlements method in User API */
- static final int VIRTUAL_DATABASE_NAME = 0;
-
- /** Position of VirtualDatabaseVersion column in server's results object returned by
- getElementEntitlements method in User API */
- static final int VIRTUAL_DATABASE_VERSION = 1;
-
- /** Position of GroupName column in server's results object returned by
- getElementEntitlements method in User API */
- static final int GROUP_NAME = 2;
-
- /** Position of ElementName column in server's results object returned by
- getElementEntitlements method in User API */
- static final int ELEMENT_NAME = 3;
-
- /** Position of Grantor column in server's results object returned by
- getElementEntitlements method in User API */
- static final int GRANTOR = 4;
-
- /** Position of Grantee column in server's results object returned by
- getElementEntitlements method in User API */
- static final int GRANTEE = 5;
-
- /** Position of Permission column in server's results object returned by
- getElementEntitlements method in User API */
- static final int PERMISSION = 6;
-
- /** Position of the column containing catalog name info. */
- static final int TABLE_CAT = 0;
-
- /** Position of the column containing privilage grantable info. */
- static final int IS_GRANTABLE = 7;
- }
-
-}
Index: utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/metadata/JDBCSQLTypeInfo.java
deleted file mode 100644
===================================================================
--- utils/modeshape-jdbc/src/main/java/org/modeshape/jdbc/metadata/JDBCSQLTypeInfo.java (revision 2552)
+++ /dev/null (working copy)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.modeshape.jdbc.metadata;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-import javax.lang.model.type.NullType;
-
-
-/**
- *