Reputation: 83
java.sql.Connection is implemented into a verbose connection to get more information for unit tests.
Using java 1.6 compiler results in following compilation errors:
The type VerboseConnection must implement the inherited abstract method Connection.createArrayOf(String, Object[])
The type VerboseConnection must implement the inherited abstract method Connection.createBlob()
The type VerboseConnection must implement the inherited abstract method Connection.createClob()
The type VerboseConnection must implement the inherited abstract method Connection.createNClob()
The type VerboseConnection must implement the inherited abstract method Connection.createSQLXML()
The type VerboseConnection must implement the inherited abstract method Connection.createStruct(String, Object[])
The type VerboseConnection must implement the inherited abstract method Connection.getClientInfo()
The type VerboseConnection must implement the inherited abstract method Connection.getClientInfo(String)
The type VerboseConnection must implement the inherited abstract method Connection.isValid(int)
The type VerboseConnection must implement the inherited abstract method Connection.setClientInfo(Properties)
The type VerboseConnection must implement the inherited abstract method Connection.setClientInfo(String, String)
The type VerboseConnection must implement the inherited abstract method Wrapper.isWrapperFor(Class)
The type VerboseConnection must implement the inherited abstract method Wrapper.unwrap(Class)
Implementing the above methods works fine in 1.6 But again if we use Java 1.5 compiler, results in the following compilation errors
NClob cannot be resolved to a type
SQLClientInfoException cannot be resolved to a type
SQLClientInfoException cannot be resolved to a type
SQLXML cannot be resolved to a type
The import java.sql.NClob cannot be resolved
The import java.sql.SQLClientInfoException cannot be resolved
The import java.sql.SQLXML cannot be resolved
Please suggest on how to make it work in both the versions with out maintaining 2 different files for different versions?
Upvotes: 1
Views: 6222
Reputation: 108971
If you need to supply both a Java 1.5 and a Java 1.6 implementation, you could use an abstract base class in your project and add a Java version dependent implementation in a separate project.
Depending on the Java version compile one or the other and include the resulting class files in your main jar file.
This is the approach we use in the implementation of Jaybird (Firebird JDBC driver).
Upvotes: 1