From 5d4023508550bd157b7945351fd5aacc9fe73def Mon Sep 17 00:00:00 2001 From: jesperpedersen Date: Fri, 8 May 2015 10:25:52 -0400 Subject: [PATCH] Move project to Java 8, and add JDBC 4.2 stubs --- .travis.yml | 4 +- pom.xml | 14 +-- .../postgres/jdbc/PGCallableStatement.java | 64 ++++++++++ .../jdbc/PGCallableStatementDelegator.java | 113 ++++++++++++++++++ .../postgres/jdbc/PGDatabaseMetaData.java | 15 +++ .../com/impossibl/postgres/jdbc/PGDriver.java | 8 +- .../postgres/jdbc/PGPreparedStatement.java | 24 ++++ .../jdbc/PGPreparedStatementDelegator.java | 44 +++++++ .../impossibl/postgres/jdbc/PGResultSet.java | 32 +++++ .../postgres/jdbc/PGSQLInputImpl.java | 7 ++ .../postgres/jdbc/PGSQLOutputImpl.java | 8 ++ .../impossibl/postgres/jdbc/PGStatement.java | 63 ++++++++++ .../postgres/jdbc/PGStatementDelegator.java | 112 +++++++++++++++++ 13 files changed, 497 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 187140bb9..376c30b9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ sudo: required language: java jdk: - - oraclejdk7 - oraclejdk8 env: - - PGVERSION=9.1 - PGVERSION=9.2 - PGVERSION=9.3 - PGVERSION=9.4 @@ -14,7 +12,7 @@ script: mvn -e test after_failure: - ./.travis/print_surefire_reports after_success: - - "test $TRAVIS_PULL_REQUEST == 'false' && test $TRAVIS_BRANCH == 'develop' && test $TRAVIS_JDK_VERSION == 'oraclejdk7' && test $PGVERSION == '9.5' && ./.travis/travis-maven-deploy" + - "test $TRAVIS_PULL_REQUEST == 'false' && test $TRAVIS_BRANCH == 'develop' && test $TRAVIS_JDK_VERSION == 'oraclejdk8' && test $PGVERSION == '9.5' && ./.travis/travis-maven-deploy" cache: directories: - '$HOME/.m2/repository' diff --git a/pom.xml b/pom.xml index 63b41bafd..5ff53bf2d 100644 --- a/pom.xml +++ b/pom.xml @@ -94,13 +94,13 @@ - org.apache.maven.plugins - maven-compiler-plugin - 3.2 - - 1.7 - 1.7 - + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + org.apache.maven.plugins diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGCallableStatement.java b/src/main/java/com/impossibl/postgres/jdbc/PGCallableStatement.java index fda83fa6e..2b923ec4c 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGCallableStatement.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGCallableStatement.java @@ -74,6 +74,7 @@ import java.sql.Ref; import java.sql.RowId; import java.sql.SQLException; +import java.sql.SQLType; import java.sql.SQLXML; import java.sql.Time; import java.sql.Timestamp; @@ -1034,4 +1035,67 @@ public void setNClob(String parameterName, Reader reader) throws SQLException { setNClob(findParameter(parameterName), reader); } + /** + * {@inheritDoc} + */ + @Override + public void setObject(String parameterName, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void setObject(String parameterName, Object x, SQLType targetSqlType) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType, int scale) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType, String typeName) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(String parameterName, SQLType sqlType) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(String parameterName, SQLType sqlType, int scale) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(String parameterName, SQLType sqlType, String typeName) throws SQLException { + throw NOT_IMPLEMENTED; + } } diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGCallableStatementDelegator.java b/src/main/java/com/impossibl/postgres/jdbc/PGCallableStatementDelegator.java index fd4069a7f..3f74a9af6 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGCallableStatementDelegator.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGCallableStatementDelegator.java @@ -41,6 +41,7 @@ import java.sql.Ref; import java.sql.RowId; import java.sql.SQLException; +import java.sql.SQLType; import java.sql.SQLXML; import java.sql.Time; import java.sql.Timestamp; @@ -1649,6 +1650,118 @@ public boolean wasNull() throws SQLException { } } + /** + * {@inheritDoc} + */ + @Override + public void setObject(String parameterName, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + try { + delegator.setObject(parameterName, x, targetSqlType, scaleOrLength); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setObject(String parameterName, Object x, SQLType targetSqlType) throws SQLException { + try { + delegator.setObject(parameterName, x, targetSqlType); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType) throws SQLException { + try { + delegator.registerOutParameter(parameterIndex, sqlType); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType, int scale) throws SQLException { + try { + delegator.registerOutParameter(parameterIndex, sqlType, scale); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(int parameterIndex, SQLType sqlType, String typeName) throws SQLException { + try { + delegator.registerOutParameter(parameterIndex, sqlType, typeName); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(String parameterName, SQLType sqlType) throws SQLException { + try { + delegator.registerOutParameter(parameterName, sqlType); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(String parameterName, SQLType sqlType, int scale) throws SQLException { + try { + delegator.registerOutParameter(parameterName, sqlType, scale); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void registerOutParameter(String parameterName, SQLType sqlType, String typeName) throws SQLException { + try { + delegator.registerOutParameter(parameterName, sqlType, typeName); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + /** * {@inheritDoc} */ diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGDatabaseMetaData.java b/src/main/java/com/impossibl/postgres/jdbc/PGDatabaseMetaData.java index 960817715..4a5dc9fdd 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGDatabaseMetaData.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGDatabaseMetaData.java @@ -2711,4 +2711,19 @@ public boolean generatedKeyAlwaysReturned() throws SQLException { return false; } + /** + * {@inheritDoc} + */ + @Override + public long getMaxLogicalLobSize() throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean supportsRefCursors() throws SQLException { + throw NOT_IMPLEMENTED; + } } diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGDriver.java b/src/main/java/com/impossibl/postgres/jdbc/PGDriver.java index 79800763c..2cc0f2e0d 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGDriver.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGDriver.java @@ -34,6 +34,7 @@ import com.impossibl.postgres.system.Version; import java.sql.Driver; +import java.sql.DriverAction; import java.sql.DriverManager; import java.sql.DriverPropertyInfo; import java.sql.SQLException; @@ -49,7 +50,7 @@ * @author Kevin Wooten * @author Jesper Pedersen */ -public class PGDriver implements Driver { +public class PGDriver implements Driver, DriverAction { /** The version of the driver */ public static final Version VERSION = Version.get(0, 1, 0); @@ -122,6 +123,11 @@ public Logger getParentLogger() throws SQLFeatureNotSupportedException { return Logger.getLogger(Context.class.getPackage().getName()); } + @Override + public void deregister() { + cleanup(); + } + public static void cleanup() { if (registered != null) { diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGPreparedStatement.java b/src/main/java/com/impossibl/postgres/jdbc/PGPreparedStatement.java index 88cdc9948..15c74231a 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGPreparedStatement.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGPreparedStatement.java @@ -73,6 +73,7 @@ import java.sql.ResultSetMetaData; import java.sql.RowId; import java.sql.SQLException; +import java.sql.SQLType; import java.sql.SQLWarning; import java.sql.SQLXML; import java.sql.Statement; @@ -951,4 +952,27 @@ public void addBatch(String sql) throws SQLException { throw NOT_ALLOWED_ON_PREP_STMT; } + /** + * {@inheritDoc} + */ + @Override + public void setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate() throws SQLException { + throw NOT_IMPLEMENTED; + } } diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGPreparedStatementDelegator.java b/src/main/java/com/impossibl/postgres/jdbc/PGPreparedStatementDelegator.java index 6384d6d3d..3d0fcb121 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGPreparedStatementDelegator.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGPreparedStatementDelegator.java @@ -44,6 +44,7 @@ import java.sql.ResultSetMetaData; import java.sql.RowId; import java.sql.SQLException; +import java.sql.SQLType; import java.sql.SQLXML; import java.sql.Time; import java.sql.Timestamp; @@ -854,6 +855,49 @@ public void setURL(int parameterIndex, URL x) throws SQLException { } } + + /** + * {@inheritDoc} + */ + @Override + public void setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + try { + delegator.setObject(parameterIndex, x, targetSqlType, scaleOrLength); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throws SQLException { + try { + delegator.setObject(parameterIndex, x, targetSqlType); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate() throws SQLException { + try { + return delegator.executeLargeUpdate(); + } + catch (SQLException se) { + owner.fireStatementError(this, se); + throw se; + } + } + /** * {@inheritDoc} */ diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGResultSet.java b/src/main/java/com/impossibl/postgres/jdbc/PGResultSet.java index f579bf2b5..c60a2dc60 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGResultSet.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGResultSet.java @@ -92,6 +92,7 @@ import java.sql.RowId; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLType; import java.sql.SQLWarning; import java.sql.SQLXML; import java.sql.Statement; @@ -1707,6 +1708,37 @@ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(getClass()); } + /** + * {@inheritDoc} + */ + @Override + public void updateObject(int columnIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void updateObject(String columnLabel, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void updateObject(int columnIndex, Object x, SQLType targetSqlType) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void updateObject(String columnLabel, Object x, SQLType targetSqlType) throws SQLException { + throw NOT_IMPLEMENTED; + } } /** diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGSQLInputImpl.java b/src/main/java/com/impossibl/postgres/jdbc/PGSQLInputImpl.java index 82194636b..d1b1e8a7d 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGSQLInputImpl.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGSQLInputImpl.java @@ -291,4 +291,11 @@ public String readNString() throws SQLException { throw NOT_SUPPORTED; } + /** + * {@inheritDoc} + */ + @Override + public T readObject(Class type) throws SQLException { + throw NOT_IMPLEMENTED; + } } diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGSQLOutputImpl.java b/src/main/java/com/impossibl/postgres/jdbc/PGSQLOutputImpl.java index c871abcbe..5abc77ef8 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGSQLOutputImpl.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGSQLOutputImpl.java @@ -54,6 +54,7 @@ import java.sql.RowId; import java.sql.SQLData; import java.sql.SQLException; +import java.sql.SQLType; import java.sql.SQLXML; import java.sql.Struct; import java.sql.Time; @@ -246,4 +247,11 @@ public void writeNClob(NClob x) throws SQLException { throw NOT_SUPPORTED; } + /** + * {@inheritDoc} + */ + @Override + public void writeObject(Object x, SQLType targetSqlType) throws SQLException { + throw NOT_IMPLEMENTED; + } } diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGStatement.java b/src/main/java/com/impossibl/postgres/jdbc/PGStatement.java index 493d39f8c..590428fcc 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGStatement.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGStatement.java @@ -704,4 +704,67 @@ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(getClass()); } + /** + * {@inheritDoc} + */ + @Override + public long getLargeUpdateCount() throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public void setLargeMaxRows(long max) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public long getLargeMaxRows() throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public long[] executeLargeBatch() throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate(String sql) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLException { + throw NOT_IMPLEMENTED; + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate(String sql, String[] columnNames) throws SQLException { + throw NOT_IMPLEMENTED; + } } diff --git a/src/main/java/com/impossibl/postgres/jdbc/PGStatementDelegator.java b/src/main/java/com/impossibl/postgres/jdbc/PGStatementDelegator.java index 32745f767..70ee1cb0f 100644 --- a/src/main/java/com/impossibl/postgres/jdbc/PGStatementDelegator.java +++ b/src/main/java/com/impossibl/postgres/jdbc/PGStatementDelegator.java @@ -415,6 +415,118 @@ public T unwrap(Class iface) throws SQLException { } } + /** + * {@inheritDoc} + */ + @Override + public long getLargeUpdateCount() throws SQLException { + try { + return delegator.getLargeUpdateCount(); + } + catch (SQLException se) { + owner.fireConnectionError(se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setLargeMaxRows(long max) throws SQLException { + try { + delegator.setLargeMaxRows(max); + } + catch (SQLException se) { + owner.fireConnectionError(se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public long getLargeMaxRows() throws SQLException { + try { + return delegator.getLargeMaxRows(); + } + catch (SQLException se) { + owner.fireConnectionError(se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public long[] executeLargeBatch() throws SQLException { + try { + return delegator.executeLargeBatch(); + } + catch (SQLException se) { + owner.fireConnectionError(se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate(String sql) throws SQLException { + try { + return delegator.executeLargeUpdate(sql); + } + catch (SQLException se) { + owner.fireConnectionError(se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + try { + return delegator.executeLargeUpdate(sql, autoGeneratedKeys); + } + catch (SQLException se) { + owner.fireConnectionError(se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLException { + try { + return delegator.executeLargeUpdate(sql, columnIndexes); + } + catch (SQLException se) { + owner.fireConnectionError(se); + throw se; + } + } + + /** + * {@inheritDoc} + */ + @Override + public long executeLargeUpdate(String sql, String[] columnNames) throws SQLException { + try { + return delegator.executeLargeUpdate(sql, columnNames); + } + catch (SQLException se) { + owner.fireConnectionError(se); + throw se; + } + } + /** * {@inheritDoc} */