From: <mro...@us...> - 2013-07-27 14:54:05
|
Revision: 58424 http://sourceforge.net/p/firebird/code/58424 Author: mrotteveel Date: 2013-07-27 14:54:02 +0000 (Sat, 27 Jul 2013) Log Message: ----------- JDBC-319 Add basic Java 8 / JDBC 4.2 support (+ upgrade ant to 1.9.2 for Java 8 support) Modified Paths: -------------- client-java/branches/Branch_2_2/.classpath client-java/branches/Branch_2_2/bin/ant client-java/branches/Branch_2_2/bin/complete-ant-cmd.pl client-java/branches/Branch_2_2/build/compile.xml client-java/branches/Branch_2_2/build/init.xml client-java/branches/Branch_2_2/lib/ant-junit.jar client-java/branches/Branch_2_2/lib/ant-launcher.jar client-java/branches/Branch_2_2/lib/ant.jar client-java/branches/Branch_2_2/src/stylesheets/junit-frames.xsl Added Paths: ----------- client-java/branches/Branch_2_2/src/jdbc_42/ client-java/branches/Branch_2_2/src/jdbc_42/org/ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/FBPooledConnection.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/RootCommonDataSource.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBCallableStatement.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBConnection.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDatabaseMetaData.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDriver.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDriverNotCapableException.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBPreparedStatement.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBResultSet.java client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBStatement.java client-java/branches/Branch_2_2/src/test_42/ client-java/branches/Branch_2_2/src/test_42/org/ client-java/branches/Branch_2_2/src/test_42/org/firebirdsql/ client-java/branches/Branch_2_2/src/test_42/org/firebirdsql/jdbc/ Modified: client-java/branches/Branch_2_2/.classpath =================================================================== --- client-java/branches/Branch_2_2/.classpath 2013-07-27 10:38:02 UTC (rev 58423) +++ client-java/branches/Branch_2_2/.classpath 2013-07-27 14:54:02 UTC (rev 58424) @@ -2,17 +2,18 @@ <classpath> <classpathentry kind="src" path="examples"/> <classpathentry kind="src" path="src/pool_jdk1_6"/> - <classpathentry kind="src" path="src/jdbc_40"/> <classpathentry kind="src" path="src/jca_jdk1_6"/> <classpathentry kind="src" path="src/wire_jdk1_4"/> <classpathentry kind="src" path="src/messages"/> <classpathentry kind="src" path="src/resources"/> <classpathentry kind="src" path="src/main"/> <classpathentry kind="src" path="src/pool"/> + <classpathentry kind="src" path="src/openoffice"/> <classpathentry excluding="org/firebirdsql/hibernate/" kind="src" path="src/test"/> <classpathentry kind="src" path="src/test_30"/> <classpathentry kind="src" path="src/test_40"/> - <classpathentry kind="src" path="src/openoffice"/> + <classpathentry kind="src" path="src/jdbc_42"/> + <classpathentry kind="src" path="src/test_42"/> <classpathentry kind="lib" path="src/lib/fscontext.jar"/> <classpathentry kind="lib" path="src/lib/providerutil.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> Modified: client-java/branches/Branch_2_2/bin/ant =================================================================== --- client-java/branches/Branch_2_2/bin/ant 2013-07-27 10:38:02 UTC (rev 58423) +++ client-java/branches/Branch_2_2/bin/ant 2013-07-27 14:54:02 UTC (rev 58424) @@ -85,7 +85,11 @@ CYGWIN*) cygwin=true ;; Darwin*) darwin=true if [ -z "$JAVA_HOME" ] ; then - JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home + if [ -x '/usr/libexec/java_home' ] ; then + JAVA_HOME=`/usr/libexec/java_home` + elif [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then + JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi fi ;; MINGW*) mingw=true ;; @@ -176,10 +180,7 @@ *.rpmnew) ;; *) for dep in `cat "$file"`; do - case "$OPT_JAR_LIST" in - *"$dep"*) ;; - *) OPT_JAR_LIST="$OPT_JAR_LIST${OPT_JAR_LIST:+ }$dep" - esac + OPT_JAR_LIST="$OPT_JAR_LIST${OPT_JAR_LIST:+ }$dep" done esac fi Modified: client-java/branches/Branch_2_2/bin/complete-ant-cmd.pl =================================================================== --- client-java/branches/Branch_2_2/bin/complete-ant-cmd.pl 2013-07-27 10:38:02 UTC (rev 58423) +++ client-java/branches/Branch_2_2/bin/complete-ant-cmd.pl 2013-07-27 14:54:02 UTC (rev 58424) @@ -19,7 +19,7 @@ # # To install for Bash 2.0 or better, add the following to ~/.bashrc: # -# $ complete -C complete-ant-cmd ant build.sh +# complete -C complete-ant-cmd.pl ant build.sh # # To install for Z-Shell 2.5 or better, add the following to ~/.zshrc: # @@ -27,7 +27,7 @@ # local args_line args # read -l args_line # set -A args $args_line -# set -A reply $(COMP_LINE=$args_line complete-ant-cmd ${args[1]} $1) +# set -A reply $(COMP_LINE=$args_line complete-ant-cmd.pl ${args[1]} $1) # } # compctl -K ant_complete ant build.sh # Modified: client-java/branches/Branch_2_2/build/compile.xml =================================================================== (Binary files differ) Modified: client-java/branches/Branch_2_2/build/init.xml =================================================================== --- client-java/branches/Branch_2_2/build/init.xml 2013-07-27 10:38:02 UTC (rev 58423) +++ client-java/branches/Branch_2_2/build/init.xml 2013-07-27 14:54:02 UTC (rev 58424) @@ -30,6 +30,26 @@ <equals arg1="${ant.java.version}" arg2="1.7"/> </or> </condition> + + <condition property="use.16.jca" value="true"> + <or> + <equals arg1="${ant.java.version}" arg2="1.6"/> + <equals arg1="${ant.java.version}" arg2="1.7"/> + <equals arg1="${ant.java.version}" arg2="1.8"/> + </or> + </condition> + + <condition property="use.16.pool" value="true"> + <or> + <equals arg1="${ant.java.version}" arg2="1.6"/> + <equals arg1="${ant.java.version}" arg2="1.7"/> + <equals arg1="${ant.java.version}" arg2="1.8"/> + </or> + </condition> + + <condition property="jdbc.42" value="true"> + <equals arg1="${ant.java.version}" arg2="1.8"/> + </condition> <!-- We set jdk1.3 property if JDK version is 1.3 --> <condition property="jdk1.3" value="true"> @@ -55,6 +75,11 @@ <condition property="jdk1.7" value="true"> <equals arg1="${ant.java.version}" arg2="1.7"/> </condition> + + <!-- We set jdk1.7 property if JDK version is 1.7 --> + <condition property="jdk1.8" value="true"> + <equals arg1="${ant.java.version}" arg2="1.8"/> + </condition> <property name="Name" value="Jaybird"/> <property name="name" value="jaybird"/> @@ -109,6 +134,7 @@ <property name="source.jdbc.20" value="${module.source}/jdbc_20"/> <property name="source.jdbc.30" value="${module.source}/jdbc_30"/> <property name="source.jdbc.40" value="${module.source}/jdbc_40"/> + <property name="source.jdbc.42" value="${module.source}/jdbc_42"/> <property name="source.wire1.3" value="${module.source}/wire_jdk1_3"/> <property name="source.wire1.4" value="${module.source}/wire_jdk1_4"/> <property name="source.pool1.4" value="${module.source}/pool_jdk1_4"/> @@ -124,6 +150,7 @@ <property name="source.test" value="${module.source}/test"/> <property name="source.test.30" value="${module.source}/test_30"/> <property name="source.test.40" value="${module.source}/test_40"/> + <property name="source.test.42" value="${module.source}/test_42"/> <property name="source.pool" value="${module.source}/pool"/> <property name="source.compatibility" value="${module.source}/compatibility"/> Modified: client-java/branches/Branch_2_2/lib/ant-junit.jar =================================================================== (Binary files differ) Modified: client-java/branches/Branch_2_2/lib/ant-launcher.jar =================================================================== (Binary files differ) Modified: client-java/branches/Branch_2_2/lib/ant.jar =================================================================== (Binary files differ) Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/FBPooledConnection.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/ds/FBPooledConnection.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/FBPooledConnection.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/FBPooledConnection.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,45 @@ +/* + * $Id$ + * + * Firebird Open Source J2EE Connector - JDBC Driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.ds; + +import javax.sql.StatementEventListener; +import java.sql.Connection; + +/** + * JDBC 4.0 implementation of PooledConnection. + * + * @author <a href="mailto:mro...@us...">Mark Rotteveel</a> + * @since 2.2 + */ +public class FBPooledConnection extends AbstractPooledConnection { + + protected FBPooledConnection(Connection connection) { + super(connection); + } + + public void addStatementEventListener(StatementEventListener listener) { + throw new UnsupportedOperationException("Not yet implemented"); + } + + public void removeStatementEventListener(StatementEventListener listener) { + throw new UnsupportedOperationException("Not yet implemented"); + } +} \ No newline at end of file Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/RootCommonDataSource.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/ds/RootCommonDataSource.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/RootCommonDataSource.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/ds/RootCommonDataSource.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,55 @@ +/* + * $Id$ + * + * Firebird Open Source J2EE Connector - JDBC Driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.ds; + +import org.firebirdsql.jdbc.FBDriverNotCapableException; + +import javax.sql.CommonDataSource; +import java.io.PrintWriter; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; + +/** + * Root superclass for the datasources in Firebird. + * <p> + * Used to workaround incompatibilities introduced for JDBC 3.0 and earlier by JDBC 4.1 (getParentLogger). + * </p> + * + * @author <a href="mailto:mro...@us...">Mark Rotteveel</a> + * @since 2.2 + */ +public abstract class RootCommonDataSource implements CommonDataSource { + + public PrintWriter getLogWriter() throws SQLException { + // Unused by Jaybird + return null; + } + + public void setLogWriter(PrintWriter out) throws SQLException { + // Unused by Jaybird + } + + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + throw new FBDriverNotCapableException(); + } + +} Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBCallableStatement.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/jdbc/FBCallableStatement.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBCallableStatement.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBCallableStatement.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,121 @@ +/* + * $Id$ + * + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. You may obtain a copy of the License at + * http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 LGPL License for more details. + * + * This file was created by members of the firebird development team. All + * individual contributions remain the Copyright (C) of those individuals. + * Contributors to this file are either listed here or can be obtained from a + * CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.jdbc; + +import org.firebirdsql.gds.impl.GDSHelper; + +import java.sql.*; + +/** + * JDBC 4.x compliant implementation of {@link java.sql.CallableStatement}. + */ +public class FBCallableStatement extends AbstractCallableStatement { + + /** + * Create instance of this class. + * + * @param c + * instance of {@link org.firebirdsql.jdbc.AbstractConnection} + * @param sql + * SQL statement containing procedure call. + * + * @throws java.sql.SQLException + * if SQL error occured. + */ + public FBCallableStatement(GDSHelper c, String sql, int rsType, int rsConcurrency, + int rsHoldability, StoredProcedureMetaData storedProcedureMetaData, + FBObjectListener.StatementListener statementListener, + FBObjectListener.BlobListener blobListener) throws SQLException { + super(c, sql, rsType, rsConcurrency, rsHoldability, storedProcedureMetaData, + statementListener, blobListener); + } + + public NClob getNClob(int parameterIndex) throws SQLException { + assertHasData(getCurrentResultSet()); + parameterIndex = procedureCall.mapOutParamIndexToPosition(parameterIndex); + return getCurrentResultSet().getNClob(parameterIndex); + } + + public NClob getNClob(String parameterName) throws SQLException { + return getNClob(findOutParameter(parameterName)); + } + + public RowId getRowId(int parameterIndex) throws SQLException { + assertHasData(getCurrentResultSet()); + parameterIndex = procedureCall.mapOutParamIndexToPosition(parameterIndex); + return getCurrentResultSet().getRowId(parameterIndex); + } + + public RowId getRowId(String parameterName) throws SQLException { + return getRowId(findOutParameter(parameterName)); + } + + public SQLXML getSQLXML(int parameterIndex) throws SQLException { + assertHasData(getCurrentResultSet()); + parameterIndex = procedureCall.mapOutParamIndexToPosition(parameterIndex); + return getCurrentResultSet().getSQLXML(parameterIndex); + } + + public SQLXML getSQLXML(String parameterName) throws SQLException { + return getSQLXML(findOutParameter(parameterName)); + } + + public void setNClob(String parameterName, NClob value) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void setRowId(String parameterName, RowId x) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { + throw new FBDriverNotCapableException(); + } + + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType) throws SQLException { + registerOutParameter(parameterIndex, sqlType.getVendorTypeNumber()); + } + + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType, int scale) throws SQLException { + registerOutParameter(parameterIndex, sqlType.getVendorTypeNumber(), scale); + } + + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType, String typeName) throws SQLException { + registerOutParameter(parameterIndex, sqlType.getVendorTypeNumber(), typeName); + } + + @Override + public void registerOutParameter(String parameterName, SQLType sqlType) throws SQLException { + registerOutParameter(parameterName, sqlType.getVendorTypeNumber()); + } + + @Override + public void registerOutParameter(String parameterName, SQLType sqlType, int scale) throws SQLException { + registerOutParameter(parameterName, sqlType.getVendorTypeNumber(), scale); + } + + @Override + public void registerOutParameter(String parameterName, SQLType sqlType, String typeName) throws SQLException { + registerOutParameter(parameterName, sqlType.getVendorTypeNumber(), typeName); + } +} Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBConnection.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/jdbc/FBConnection.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBConnection.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBConnection.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,207 @@ +/* + * $Id$ + * + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.jdbc; + +import org.firebirdsql.jca.FBManagedConnection; +import org.firebirdsql.util.SQLExceptionChainBuilder; + +import java.sql.*; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +/** + * Firebird connection class implementing JDBC 3.0 methods. + * + * @author <a href="mailto:rro...@us...">Roman Rokytskyy</a> + */ +public class FBConnection extends AbstractConnection { + + private HashSet clientInfoPropNames = new HashSet(); + + /** + * Create instance of this class for the specified managed connection. + * + * @param mc + * managed connection. + */ + public FBConnection(FBManagedConnection mc) { + super(mc); + } + + // ------------------------------------------------------------------------- + // JDBC 4.0 + // ------------------------------------------------------------------------- + + public NClob createNClob() throws SQLException { + throw new FBDriverNotCapableException(); + } + + public SQLXML createSQLXML() throws SQLException { + throw new FBDriverNotCapableException(); + } + + private static final String GET_CLIENT_INFO_SQL = + "SELECT " + + " rdb$get_context('USER_SESSION', ?) session_context " + + " , rdb$get_context('USER_TRANSACTION', ?) tx_context " + + "FROM rdb$database"; + + private static final String SET_CLIENT_INFO_SQL = + "SELECT " + + " rdb$set_context('USER_SESSION', ?, ?) session_context " + + "FROM rdb$database"; + + public Properties getClientInfo() throws SQLException { + Properties result = new Properties(); + + PreparedStatement stmt = prepareStatement(GET_CLIENT_INFO_SQL); + try { + for (Iterator iterator = clientInfoPropNames.iterator(); iterator.hasNext();) { + String propName = (String) iterator.next(); + result.put(propName, getClientInfo(stmt, propName)); + } + } finally { + stmt.close(); + } + + return result; + } + + public String getClientInfo(String name) throws SQLException { + PreparedStatement stmt = prepareStatement(GET_CLIENT_INFO_SQL); + try { + return getClientInfo(stmt, name); + } finally { + stmt.close(); + } + } + + protected String getClientInfo(PreparedStatement stmt, String name) throws SQLException { + stmt.clearParameters(); + + stmt.setString(1, name); + stmt.setString(2, name); + + ResultSet rs = stmt.executeQuery(); + try { + if (!rs.next()) + return null; + + String sessionContext = rs.getString(1); + String transactionContext = rs.getString(2); + + if (transactionContext != null) + return transactionContext; + else if (sessionContext != null) + return sessionContext; + else + return null; + + } finally { + rs.close(); + } + + } + + public void setClientInfo(Properties properties) throws SQLClientInfoException { + SQLExceptionChainBuilder<SQLClientInfoException> chain = new SQLExceptionChainBuilder<SQLClientInfoException>(); + + try { + PreparedStatement stmt = prepareStatement(SET_CLIENT_INFO_SQL); + try { + + for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + + try { + setClientInfo(stmt, (String) entry.getKey(), (String) entry.getValue()); + } catch (SQLClientInfoException ex) { + chain.append(ex); + } + + } + } finally { + stmt.close(); + } + + } catch (SQLException ex) { + throw new SQLClientInfoException(ex.getMessage(), ex.getSQLState(), null, ex); + } + + if (chain.hasException()) + throw chain.getException(); + } + + public void setClientInfo(String name, String value) throws SQLClientInfoException { + try { + PreparedStatement stmt = prepareStatement(SET_CLIENT_INFO_SQL); + try { + setClientInfo(stmt, name, value); + } finally { + stmt.close(); + } + + } catch (SQLException ex) { + throw new SQLClientInfoException(ex.getMessage(), ex.getSQLState(), null, ex); + } + } + + protected void setClientInfo(PreparedStatement stmt, String name, String value) + throws SQLException { + try { + stmt.clearParameters(); + stmt.setString(1, name); + stmt.setString(2, value); + + ResultSet rs = stmt.executeQuery(); + if (!rs.next()) + throw new FBDriverConsistencyCheckException( + "Expected result from RDB$SET_CONTEXT call"); + + // needed, since the value is set on fetch!!! + rs.getInt(1); + + } catch (SQLException ex) { + throw new SQLClientInfoException(null, ex); + } + } + + public void abort(Executor executor) throws SQLException { + // TODO Write implementation + checkValidity(); + throw new FBDriverNotCapableException(); + } + + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + // TODO Write implementation + checkValidity(); + throw new FBDriverNotCapableException(); + } + + public int getNetworkTimeout() throws SQLException { + // TODO Write implementation + checkValidity(); + return 0; + } +} Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDatabaseMetaData.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/jdbc/FBDatabaseMetaData.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDatabaseMetaData.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDatabaseMetaData.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,86 @@ +/* + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.jdbc; + +import org.firebirdsql.gds.GDSException; +import org.firebirdsql.gds.impl.GDSHelper; + +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.sql.RowIdLifetime; +import java.sql.SQLException; + +public class FBDatabaseMetaData extends AbstractDatabaseMetaData { + + public FBDatabaseMetaData(AbstractConnection c) throws GDSException { + super(c); + } + + public FBDatabaseMetaData(GDSHelper gdsHelper) { + super(gdsHelper); + } + + /** + * Indicates whether or not this data source supports the SQL <code>ROWID</code> type, + * and if so the lifetime for which a <code>RowId</code> object remains valid. + * <p> + * The returned int values have the following relationship: + * <pre> + * ROWID_UNSUPPORTED < ROWID_VALID_OTHER < ROWID_VALID_TRANSACTION + * < ROWID_VALID_SESSION < ROWID_VALID_FOREVER + * </pre> + * so conditional logic such as + * <pre> + * if (metadata.getRowIdLifetime() > DatabaseMetaData.ROWID_VALID_TRANSACTION) + * </pre> + * can be used. Valid Forever means valid across all Sessions, and valid for + * a Session means valid across all its contained Transactions. + * + * @return the status indicating the lifetime of a <code>RowId</code> + * @throws java.sql.SQLException if a database access error occurs + * @since 1.6 + */ + public RowIdLifetime getRowIdLifetime() throws SQLException { + return RowIdLifetime.ROWID_UNSUPPORTED; + } + + public int getJDBCMajorVersion() { + return 4; + } + + public int getJDBCMinorVersion() { + try { + String javaImplementation = AccessController.doPrivileged(new PrivilegedAction<String>() { + public String run() { + return System.getProperty("java.specification.version"); + } + }); + if (javaImplementation != null && "1.7".compareTo(javaImplementation) <= 0) { + // JDK 1.7 or higher: JDBC 4.1 + return 1; + } else { + // JDK 1.6 (or lower): JDBC 4.0 + return 0; + } + } catch (RuntimeException ex) { + // default to 0 (JDBC 4.0) when privileged call fails + return 0; + } + } +} Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDriver.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/jdbc/FBDriver.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDriver.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDriver.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,40 @@ +/* + * $Id$ + * + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.jdbc; + + +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; + +/** + * The Jaybird JDBC Driver implementation for the Firebird database. + * + * @author <a href="mailto:d_j...@us...">David Jencks</a> + * @version 1.0 + */ +public class FBDriver extends AbstractDriver implements FirebirdDriver { + + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + throw new FBDriverNotCapableException(); + } + +} + Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDriverNotCapableException.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/jdbc/FBDriverNotCapableException.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDriverNotCapableException.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBDriverNotCapableException.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,48 @@ +/* + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.jdbc; + +import java.sql.SQLFeatureNotSupportedException; + + +/** + * Tell that driver is not able to serve the request due to missing capabilities. + * + * @author <a href="mailto:rro...@us...">Roman Rokytskyy</a> + */ +public class FBDriverNotCapableException extends SQLFeatureNotSupportedException { + public static final String SQL_STATE_FEATURE_NOT_SUPPORTED = "0A000"; + + /** + * Create instance of this class for the specified reason. + * + * @param reason reason that will be displayed. + */ + public FBDriverNotCapableException(String reason) { + super(reason, SQL_STATE_FEATURE_NOT_SUPPORTED); + } + + /** + * Create instance of this class. + */ + public FBDriverNotCapableException() { + super("Not yet implemented.", SQL_STATE_FEATURE_NOT_SUPPORTED); + } + +} Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBPreparedStatement.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/jdbc/FBPreparedStatement.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBPreparedStatement.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBPreparedStatement.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,82 @@ +/* + * $Id$ + * + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.jdbc; + +import org.firebirdsql.gds.impl.GDSHelper; +import org.firebirdsql.jdbc.FBObjectListener.BlobListener; +import org.firebirdsql.jdbc.FBObjectListener.StatementListener; + +import java.sql.*; + +/** + * JDBC-4.x implementation of {@link java.sql.PreparedStatement}. + * + * @author <a href="mailto:rro...@us...">Roman Rokytskyy</a> + */ +public class FBPreparedStatement extends AbstractPreparedStatement { + + public FBPreparedStatement(GDSHelper c, int rsType, int rsConcurrency, int rsHoldability, + StatementListener statementListener, BlobListener blobListener) throws SQLException { + super(c, rsType, rsConcurrency, rsHoldability, statementListener, blobListener); + } + + public FBPreparedStatement(GDSHelper gdsHelper, String sql, int rsType, int rsConcurrency, + int rsHoldability, StatementListener statementListener, + BlobListener blobListener, boolean metaDataQuery, + boolean standaloneStatement, boolean generatedKeys) throws SQLException { + super(gdsHelper, sql, rsType, rsConcurrency, rsHoldability, statementListener, + blobListener, metaDataQuery, standaloneStatement, generatedKeys); + } + + public void setNClob(int parameterIndex, NClob value) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void setRowId(int parameterIndex, RowId x) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + throw new FBDriverNotCapableException(); + } + + @Override + public void setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + setObject(parameterIndex, x, targetSqlType.getVendorTypeNumber(), scaleOrLength); + } + + @Override + public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throws SQLException { + setObject(parameterIndex, x, targetSqlType.getVendorTypeNumber()); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support update counts exceeding {@link Integer#MAX_VALUE}, this method calls + * {@link #executeUpdate()}. + * </p> + */ + @Override + public long executeLargeUpdate() throws SQLException { + return executeUpdate(); + } +} Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBResultSet.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/jdbc/FBResultSet.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBResultSet.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBResultSet.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,166 @@ +/* + * $Id$ + * + * Firebird Open Source J2ee connector - jdbc driver + * + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program 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 + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. + */ +package org.firebirdsql.jdbc; + +import org.firebirdsql.gds.XSQLVAR; +import org.firebirdsql.gds.impl.AbstractIscStmtHandle; +import org.firebirdsql.gds.impl.GDSHelper; +import org.firebirdsql.jdbc.FBObjectListener.ResultSetListener; + +import java.io.Reader; +import java.sql.*; +import java.util.ArrayList; + +/** + * Implementation of {@link java.sql.ResultSet} interface. + * + * @author <a href="mailto:d_j...@us...">David Jencks</a> + * @author <a href="mailto:rro...@us...">Roman Rokytskyy</a> + * @author <a href="mailto:mro...@us...">Mark Rotteveel</a> + */ +public class FBResultSet extends AbstractResultSet { + + public FBResultSet(GDSHelper gdsHelper, AbstractStatement fbStatement, + AbstractIscStmtHandle stmt, ResultSetListener listener, + boolean metaDataQuery, int rsType, int rsConcurrency, + int rsHoldability, boolean cached) throws SQLException { + + super(gdsHelper, fbStatement, stmt, listener, metaDataQuery, rsType, + rsConcurrency, rsHoldability, cached); + } + + public FBResultSet(XSQLVAR[] xsqlvars, ArrayList rows) throws SQLException { + super(xsqlvars, rows); + } + + public NClob getNClob(int columnIndex) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public NClob getNClob(String columnLabel) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public RowId getRowId(int columnIndex) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public RowId getRowId(String columnLabel) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public SQLXML getSQLXML(int columnIndex) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public SQLXML getSQLXML(String columnLabel) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateNClob(int columnIndex, NClob clob) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateNClob(int columnIndex, Reader reader, long length) + throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateNClob(String columnLabel, NClob clob) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateNClob(String columnLabel, Reader reader, long length) + throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateNClob(String columnLabel, Reader reader) + throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateRowId(int columnIndex, RowId x) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateRowId(String columnLabel, RowId x) throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateSQLXML(int columnIndex, SQLXML xmlObject) + throws SQLException { + throw new FBDriverNotCapableException(); + } + + public void updateSQLXML(String columnLabel, SQLXML xmlObject) + throws SQLException { + throw new FBDriverNotCapableException(); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird delegates to {@link #updateObject(int, Object, int)} and ignores the value of <code>targetSqlType</code> + * </p> + */ + @Override + public void updateObject(int columnIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + updateObject(columnIndex, x, scaleOrLength); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird delegates to {@link #updateObject(String, Object, int)} and ignores the value of <code>targetSqlType</code> + * </p> + */ + @Override + public void updateObject(String columnLabel, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + updateObject(columnLabel, x, scaleOrLength); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird delegates to {@link #updateObject(int, Object)} and ignores the value of <code>targetSqlType</code> + * </p> + */ + @Override + public void updateObject(int columnIndex, Object x, SQLType targetSqlType) throws SQLException { + updateObject(columnIndex, x); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird delegates to {@link #updateObject(String, Object)} and ignores the value of <code>targetSqlType</code> + * </p> + */ + @Override + public void updateObject(String columnLabel, Object x, SQLType targetSqlType) throws SQLException { + updateObject(columnLabel, x); + } +} Copied: client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBStatement.java (from rev 58342, client-java/branches/Branch_2_2/src/jdbc_40/org/firebirdsql/jdbc/FBStatement.java) =================================================================== --- client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBStatement.java (rev 0) +++ client-java/branches/Branch_2_2/src/jdbc_42/org/firebirdsql/jdbc/FBStatement.java 2013-07-27 14:54:02 UTC (rev 58424) @@ -0,0 +1,132 @@ +package org.firebirdsql.jdbc; + +import org.firebirdsql.gds.impl.GDSHelper; + +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLNonTransientException; +import java.sql.SQLWarning; +import java.util.logging.Logger; + +/** + * + * @author <a href="mailto:rro...@us...">Roman Rokytskyy</a> + */ +public class FBStatement extends AbstractStatement { + + public FBStatement(GDSHelper c, int rsType, int rsConcurrency, int rsHoldability, + FBObjectListener.StatementListener statementListener) throws SQLException { + super(c, rsType, rsConcurrency, rsHoldability, statementListener); + } + + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + throw new FBDriverNotCapableException(); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support large update counts, the return value of this method is the same as + * {@link #getUpdateCount()}. + * </p> + */ + @Override + public long getLargeUpdateCount() throws SQLException { + return getUpdateCount(); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support maxRows exceeding {@link Integer#MAX_VALUE}, if a larger value is set, Jaybird will + * add a warning to the statement and reset the maximum to 0. + * </p> + */ + @Override + public void setLargeMaxRows(long max) throws SQLException { + if (max > Integer.MAX_VALUE) { + addWarning(new SQLWarning( + String.format("Implementation limit: maxRows cannot exceed Integer.MAX_VALUE, value was %d, reset to 0", max), + FBSQLException.SQL_STATE_INVALID_ARG_VALUE)); + max = 0; + } + setMaxRows((int) max); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support maxRows exceeding {@link Integer#MAX_VALUE}, the return value of this method is the + * same as {@link #getMaxRows()}. + * </p> + */ + @Override + public long getLargeMaxRows() throws SQLException { + return getMaxRows(); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support update counts exceeding {@link Integer#MAX_VALUE}, this method calls + * {@link #executeBatch()} and converts the int-array to a long-array. + * </p> + */ + @Override + public long[] executeLargeBatch() throws SQLException { + int[] updateCountsInt = executeBatch(); + long[] updateCountsLong = new long[updateCountsInt.length]; + for (int i = 0; i < updateCountsInt.length; i++) { + updateCountsLong[i] = updateCountsInt[i]; + } + return updateCountsLong; + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support update counts exceeding {@link Integer#MAX_VALUE}, this method calls + * {@link #executeUpdate(String)}. + * </p> + */ + @Override + public long executeLargeUpdate(String sql) throws SQLException { + return executeUpdate(sql); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support update counts exceeding {@link Integer#MAX_VALUE}, this method calls + * {@link #executeUpdate(String,int)}. + * </p> + */ + @Override + public long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + return executeUpdate(sql, autoGeneratedKeys); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support update counts exceeding {@link Integer#MAX_VALUE}, this method calls + * {@link #executeUpdate(String,int[])}. + * </p> + */ + @Override + public long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLException { + return executeUpdate(sql, columnIndexes); + } + + /** + * {@inheritDoc} + * <p> + * Jaybird does not support update counts exceeding {@link Integer#MAX_VALUE}, this method calls + * {@link #executeUpdate(String,String[])}. + * </p> + */ + @Override + public long executeLargeUpdate(String sql, String[] columnNames) throws SQLException { + return executeUpdate(sql, columnNames); + } +} Modified: client-java/branches/Branch_2_2/src/stylesheets/junit-frames.xsl =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |