33import org .utplsql .api .DBHelper ;
44import org .utplsql .api .TestRunnerOptions ;
55import org .utplsql .api .Version ;
6+ import org .utplsql .api .db .DatabaseInformation ;
7+ import org .utplsql .api .db .DefaultDatabaseInformation ;
68import org .utplsql .api .exception .DatabaseNotCompatibleException ;
79import org .utplsql .api .outputBuffer .OutputBuffer ;
810import org .utplsql .api .outputBuffer .OutputBufferProvider ;
@@ -29,14 +31,25 @@ public class CompatibilityProxy {
2931
3032 private Version databaseVersion ;
3133 private boolean compatible = false ;
34+ private DatabaseInformation databaseInformation ;
3235
33- public CompatibilityProxy ( Connection conn ) throws SQLException
34- {
35- this (conn , false );
36+ public CompatibilityProxy ( Connection conn ) throws SQLException {
37+ this (conn , false , null );
3638 }
3739
38- public CompatibilityProxy ( Connection conn , boolean skipCompatibilityCheck ) throws SQLException
39- {
40+ public CompatibilityProxy ( Connection conn , DatabaseInformation databaseInformation ) throws SQLException {
41+ this (conn , false , databaseInformation );
42+ }
43+
44+ public CompatibilityProxy ( Connection conn , boolean skipCompatibilityCheck ) throws SQLException {
45+ this (conn , skipCompatibilityCheck , null );
46+ }
47+
48+ public CompatibilityProxy ( Connection conn , boolean skipCompatibilityCheck , DatabaseInformation databaseInformation ) throws SQLException {
49+ this .databaseInformation = (databaseInformation != null )
50+ ? databaseInformation
51+ : new DefaultDatabaseInformation ();
52+
4053 if ( skipCompatibilityCheck )
4154 doExpectCompatibility ();
4255 else
@@ -51,7 +64,7 @@ public CompatibilityProxy( Connection conn, boolean skipCompatibilityCheck ) thr
5164 */
5265 private void doCompatibilityCheckWithDatabase ( Connection conn ) throws SQLException
5366 {
54- databaseVersion = DBHelper . getDatabaseFrameworkVersion (conn );
67+ databaseVersion = databaseInformation . getUtPlsqlFrameworkVersion (conn );
5568 Version clientVersion = new Version (UTPLSQL_COMPATIBILITY_VERSION );
5669
5770 if ( databaseVersion == null )
@@ -87,17 +100,8 @@ private void doExpectCompatibility()
87100 */
88101 private boolean versionCompatibilityCheck (Connection conn , String requested , String current )
89102 throws SQLException {
90- try (CallableStatement callableStatement = conn .prepareCall ("BEGIN ? := ut_runner.version_compatibility_check(?, ?); END;" )) {
91- callableStatement .registerOutParameter (1 , Types .SMALLINT );
92- callableStatement .setString (2 , requested );
93-
94- if (current == null )
95- callableStatement .setNull (3 , Types .VARCHAR );
96- else
97- callableStatement .setString (3 , current );
98-
99- callableStatement .executeUpdate ();
100- return callableStatement .getInt (1 ) == 1 ;
103+ try {
104+ return databaseInformation .frameworkCompatibilityCheck (conn , requested , current ) == 1 ;
101105 } catch (SQLException e ) {
102106 if (e .getErrorCode () == 6550 )
103107 return false ;
0 commit comments