Skip to content

Commit

Permalink
JDBC-185: Add base implementations for JDBC 4.1 methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotteveel committed Sep 25, 2011
1 parent ce41b62 commit 154f41b
Show file tree
Hide file tree
Showing 35 changed files with 621 additions and 219 deletions.
15 changes: 11 additions & 4 deletions build/compile.xml
Expand Up @@ -18,6 +18,7 @@
<javac srcdir="${source.examples}"
destdir="${build.examples}"
target="${ant.java.version}"
source="${ant.java.version}"
debug="on"
deprecation="on"
optimize="on"
Expand Down Expand Up @@ -58,7 +59,7 @@
</path>
</target>

<target name="set-pool1.4-src" unless="jdk1.5">
<target name="set-pool1.4-src" if="jdk1.4">
<path id="source.java.pool">
<pathelement path="${source.pool1.4}"/>
</path>
Expand All @@ -70,7 +71,7 @@
</path>
</target>

<target name="set-pool1.6-src" if="jdk1.6">
<target name="set-pool1.6-src" if="jdbc.40">
<path id="source.java.pool">
<pathelement path="${source.pool1.6}"/>
</path>
Expand All @@ -89,13 +90,13 @@
</path>
</target>

<target name="set-jca-src-14" unless="jdk1.6">
<target name="set-jca-src-14" unless="jdbc.40">
<path id="source.java.jca">
<pathelement path="${source.jca1.4}"/>
</path>
</target>

<target name="set-jca-src-16" if="jdk1.6">
<target name="set-jca-src-16" if="jdbc.40">
<path id="source.java.jca">
<pathelement path="${source.jca1.6}"/>
</path>
Expand All @@ -105,13 +106,15 @@
<mkdir dir="${build.classes}"/>

<echo message="${jdk1.3}"/>
<echo message="${ant.java.version}"/>
<echo message="${toString:source.java.openoffice}"/>
<echo message="${toString:source.java.additional}"/>
<echo message="${toString:source.java.wire}"/>
<echo message="${toString:source.java.jca}"/>

<javac destdir="${build.classes}"
target="${ant.java.version}"
source="${ant.java.version}"
debug="on"
deprecation="on"
optimize="on"
Expand All @@ -129,9 +132,11 @@

<target name="compile-pool" depends="set-pool1.4-src,set-pool1.5-src,set-pool1.6-src,compile-driver">
<mkdir dir="${build.pool}"/>
<echo message="${toString:source.java.pool}"/>
<javac srcdir="${source.pool}"
destdir="${build.pool}"
target="${ant.java.version}"
source="${ant.java.version}"
debug="on"
deprecation="on"
optimize="on"
Expand All @@ -148,6 +153,7 @@
<javac srcdir="${source.compatibility}"
destdir="${build.compatibility}"
target="${ant.java.version}"
source="${ant.java.version}"
debug="on"
deprecation="on"
optimize="on"
Expand Down Expand Up @@ -179,6 +185,7 @@
<javac
destdir="${build.test}"
target="${ant.java.version}"
source="${ant.java.version}"
debug="on"
deprecation="on"
optimize="on"
Expand Down
14 changes: 12 additions & 2 deletions build/init.xml
Expand Up @@ -24,7 +24,11 @@
</condition>

<condition property="jdbc.40" value="true">
<equals arg1="${ant.java.version}" arg2="1.6"/>
<or>
<equals arg1="${ant.java.version}" arg2="1.6"/>
<!-- Technically JDK 1.7 is JDBC 4.1, we use this here as un indication to use the jdbc4.0 sources -->
<equals arg1="${ant.java.version}" arg2="1.7"/>
</or>
</condition>

<!-- We set jdk1.3 property if JDK version is 1.3 -->
Expand All @@ -47,6 +51,11 @@
<equals arg1="${ant.java.version}" arg2="1.6"/>
</condition>

<!-- We set jdk1.7 property if JDK version is 1.7 -->
<condition property="jdk1.7" value="true">
<equals arg1="${ant.java.version}" arg2="1.7"/>
</condition>

<property name="Name" value="Jaybird"/>
<property name="name" value="jaybird"/>

Expand Down Expand Up @@ -180,7 +189,7 @@

<property name="packages" value="org.firebirdsql.gds,org.firebirdsql.jca,org.firebirdsql.jdbc,org.firebirdsql.management,org.firebirdsql.pool,org.firebirdsql.event"/>

<property name="build.compiler" value="classic"/>
<property name="build.compiler" value="modern"/>

<path id="javac.j2ee.classpath">
<pathelement location="${module.thirdparty}/mini-j2ee.jar"/>
Expand All @@ -191,6 +200,7 @@
<path refid="javac.j2ee.classpath"/>
<pathelement location="${build.j2ee}"/>
<pathelement location="${module.thirdparty}/log4j-core.jar"/>
<pathelement location="${lib.dir}/antlr-runtime-3.0.1.jar"/>
</path>

<path id="javac.pool.classpath">
Expand Down
10 changes: 9 additions & 1 deletion build/test.xml
Expand Up @@ -40,6 +40,7 @@

<fileset dir="lib">
<include name="**/*.jar"/>
<exclude name="**/ant.jar **/ant-*.jar"/>
</fileset>

<path refid="javac.test.classpath"/>
Expand Down Expand Up @@ -105,6 +106,7 @@

<fileset dir="lib">
<include name="**/*.jar"/>
<exclude name="**/ant.jar **/ant-*.jar"/>
</fileset>

<path refid="javac.test.classpath"/>
Expand Down Expand Up @@ -173,6 +175,7 @@

<fileset dir="lib">
<include name="**/*.jar"/>
<exclude name="**/ant.jar **/ant-*.jar"/>
</fileset>

<path refid="javac.test.classpath"/>
Expand Down Expand Up @@ -231,7 +234,10 @@
<pathelement location="${build.classes}"/>
<pathelement location="${build.test}"/>
<pathelement location="${build.resources}"/>
<pathelement location="${lib.dir}/*.jar"/>
<fileset dir="lib">
<include name="**/*.jar"/>
<exclude name="**/ant.jar **/ant-*.jar"/>
</fileset>
<path refid="javac.test.classpath"/>
</classpath>

Expand Down Expand Up @@ -283,6 +289,7 @@

<fileset dir="lib">
<include name="**/*.jar"/>
<exclude name="**/ant.jar **/ant-*.jar"/>
</fileset>

<path refid="javac.test.classpath"/>
Expand Down Expand Up @@ -331,6 +338,7 @@

<fileset dir="lib">
<include name="**/*.jar"/>
<exclude name="**/ant.jar **/ant-*.jar"/>
</fileset>

<path refid="javac.test.classpath"/>
Expand Down
45 changes: 45 additions & 0 deletions src/jdbc_30/org/firebirdsql/ds/RootCommonDataSource.java
@@ -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 java.io.PrintWriter;
import java.sql.SQLException;

/**
* 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:mrotteveel@users.sourceforge.net">Mark Rotteveel</a>
* @since 2.2
*/
public abstract class RootCommonDataSource {

public PrintWriter getLogWriter() throws SQLException {
// Unused by Jaybird
return null;
}

public void setLogWriter(PrintWriter out) throws SQLException {
// Unused by Jaybird
}
}
33 changes: 33 additions & 0 deletions src/jdbc_30/org/firebirdsql/jdbc/FBDriver.java
@@ -0,0 +1,33 @@
/*
* $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.*;

/**
* The Jaybird JDBC Driver implementation for the Firebird database.
*
* @author <a href="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
* @version 1.0
*/
public class FBDriver extends AbstractDriver implements FirebirdDriver {
}

Expand Up @@ -25,22 +25,22 @@
* @author <a href="mailto:rrokytskyy@users.sourceforge.net">Roman Rokytskyy</a>
*/
public class FBDriverNotCapableException extends FBSQLException {
public static final String SQL_STATE_DRIVER_NOT_CAPABLE = "HYC00";
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_DRIVER_NOT_CAPABLE);
super(reason, SQL_STATE_FEATURE_NOT_SUPPORTED);
}

/**
* Create instance of this class.
*/
public FBDriverNotCapableException() {
super("Not yet implemented.");
super("Not yet implemented.", SQL_STATE_FEATURE_NOT_SUPPORTED);
}

}
56 changes: 56 additions & 0 deletions src/jdbc_40/org/firebirdsql/ds/RootCommonDataSource.java
@@ -0,0 +1,56 @@
/*
* $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 java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;

import javax.sql.CommonDataSource;

import org.firebirdsql.jdbc.FBDriverNotCapableException;

/**
* 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:mrotteveel@users.sourceforge.net">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();
}

}
13 changes: 11 additions & 2 deletions src/jdbc_40/org/firebirdsql/jdbc/FBCallableStatement.java
Expand Up @@ -23,7 +23,6 @@
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import java.util.Map;

import org.firebirdsql.gds.GDSException;
import org.firebirdsql.gds.impl.GDSHelper;
Expand Down Expand Up @@ -500,7 +499,17 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
if (!isWrapperFor(iface))
throw new FBDriverNotCapableException();

return (T)this;
return iface.cast(this);
}

public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException {
// TODO Write implementation
throw new FBDriverNotCapableException();
}

public <T> T getObject(String parameterName, Class<T> type) throws SQLException {
// TODO Write implementation
throw new FBDriverNotCapableException();
}

}

0 comments on commit 154f41b

Please sign in to comment.