|
3 | 3 | import org.utplsql.api.DBHelper;
|
4 | 4 | import org.utplsql.api.TestRunnerOptions;
|
5 | 5 | import org.utplsql.api.Version;
|
| 6 | +import org.utplsql.api.db.DatabaseInformation; |
| 7 | +import org.utplsql.api.db.DefaultDatabaseInformation; |
6 | 8 | import org.utplsql.api.exception.DatabaseNotCompatibleException;
|
7 | 9 | import org.utplsql.api.outputBuffer.OutputBuffer;
|
8 | 10 | import org.utplsql.api.outputBuffer.OutputBufferProvider;
|
@@ -29,14 +31,25 @@ public class CompatibilityProxy {
|
29 | 31 |
|
30 | 32 | private Version databaseVersion;
|
31 | 33 | private boolean compatible = false;
|
| 34 | +private DatabaseInformation databaseInformation; |
32 | 35 |
|
33 |
| -public CompatibilityProxy( Connection conn ) throws SQLException |
34 |
| -{ |
35 |
| -this(conn, false); |
| 36 | +public CompatibilityProxy( Connection conn ) throws SQLException { |
| 37 | +this(conn, false, null); |
36 | 38 | }
|
37 | 39 |
|
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 | + |
40 | 53 | if ( skipCompatibilityCheck )
|
41 | 54 | doExpectCompatibility();
|
42 | 55 | else
|
@@ -51,7 +64,7 @@ public CompatibilityProxy( Connection conn, boolean skipCompatibilityCheck ) thr
|
51 | 64 | */
|
52 | 65 | private void doCompatibilityCheckWithDatabase( Connection conn ) throws SQLException
|
53 | 66 | {
|
54 |
| -databaseVersion = DBHelper.getDatabaseFrameworkVersion(conn); |
| 67 | +databaseVersion = databaseInformation.getUtPlsqlFrameworkVersion(conn); |
55 | 68 | Version clientVersion = new Version(UTPLSQL_COMPATIBILITY_VERSION);
|
56 | 69 |
|
57 | 70 | if ( databaseVersion == null )
|
@@ -87,17 +100,8 @@ private void doExpectCompatibility()
|
87 | 100 | */
|
88 | 101 | private boolean versionCompatibilityCheck(Connection conn, String requested, String current)
|
89 | 102 | 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; |
101 | 105 | } catch (SQLException e) {
|
102 | 106 | if (e.getErrorCode() == 6550)
|
103 | 107 | return false;
|
|
0 commit comments