Skip to content

Commit 73de352

Browse files
committed
register custom PG data-types on newConnection + support JDBC < 4 driver
1 parent b385ef5 commit 73de352

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,22 @@ protected String caseConvertIdentifierForJdbc(final Connection connection, final
119119
}
120120

121121
@Override
122-
protected void setStatementParameters(final ThreadContext context,
123-
final Connection connection, final PreparedStatement statement,
124-
final List<?> binds) throws SQLException {
125-
126-
final PGConnection pgConnection = connection.unwrap(PGConnection.class);
122+
protected Connection newConnection() throws SQLException {
123+
final Connection connection = getConnectionFactory().newConnection();
124+
final PGConnection pgConnection;
125+
if ( connection instanceof PGConnection ) {
126+
pgConnection = (PGConnection) connection;
127+
}
128+
else {
129+
pgConnection = connection.unwrap(PGConnection.class);
130+
}
127131
pgConnection.addDataType("daterange", DateRangeType.class);
128132
pgConnection.addDataType("tsrange", TsRangeType.class);
129133
pgConnection.addDataType("tstzrange", TstzRangeType.class);
130134
pgConnection.addDataType("int4range", Int4RangeType.class);
131135
pgConnection.addDataType("int8range", Int8RangeType.class);
132136
pgConnection.addDataType("numrange", NumRangeType.class);
133-
134-
super.setStatementParameters(context, connection, statement, binds);
137+
return connection;
135138
}
136139

137140
@Override // due statement.setNull(index, Types.BLOB) not working :

0 commit comments

Comments
 (0)