Skip to content

Commit 22a5603

Browse files
pesseSamuel Nitsche
authored andcommitted
Only check for orai18n when we are on a 11g database
the library is not needed for 12c
1 parent c147d5c commit 22a5603

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

src/main/java/org/utplsql/cli/ConnectionInfo.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66

77
import java.io.File;
88
import java.sql.Connection;
9+
import java.sql.PreparedStatement;
10+
import java.sql.ResultSet;
911
import java.sql.SQLException;
1012

1113
public class ConnectionInfo {
1214

15+
private String databaseVersion;
16+
1317
static {
1418
String oracleHome = System.getenv("ORACLE_HOME");
1519
if (oracleHome != null) {
@@ -42,4 +46,40 @@ public ConnectionInfo convert(String s) {
4246
}
4347
}
4448

49+
public String getOracleDatabaseVersion() throws SQLException
50+
{
51+
try ( Connection conn = getConnection() ) {
52+
return getOracleDatabaseVersion(conn);
53+
}
54+
}
55+
56+
public String getOracleDatabaseVersion( Connection conn ) throws SQLException
57+
{
58+
if ( databaseVersion == null ) {
59+
databaseVersion = getOracleDatabaseVersionFromConnection( conn );
60+
}
61+
62+
return databaseVersion;
63+
}
64+
65+
/** TODO: Outsource this to Java-API
66+
*
67+
* @param conn
68+
* @return
69+
* @throws SQLException
70+
*/
71+
public static String getOracleDatabaseVersionFromConnection( Connection conn ) throws SQLException {
72+
assert conn != null;
73+
String result = null;
74+
try (PreparedStatement stmt = conn.prepareStatement("select version from product_component_version where product like 'Oracle Database%'"))
75+
{
76+
ResultSet rs = stmt.executeQuery();
77+
78+
if ( rs.next() )
79+
result = rs.getString(1);
80+
}
81+
82+
return result;
83+
}
84+
4585
}

src/main/java/org/utplsql/cli/RunCommand.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public List<String> getTestPaths() {
9090

9191
public int run() throws Exception {
9292

93-
checkOracleLibrariesExist();
93+
checkOracleJDBCExists();
9494

9595
final ConnectionInfo ci = getConnectionInfo();
9696

@@ -110,6 +110,9 @@ public int run() throws Exception {
110110
// Do the reporters initialization, so we can use the id to run and gather results.
111111
try (Connection conn = ci.getConnection()) {
112112

113+
// Check if orai18n exists if database version is 11g
114+
checkOracleI18nExists(ci.getOracleDatabaseVersion(conn));
115+
113116
// First of all do a compatibility check and fail-fast
114117
checkFrameworkCompatibility(conn);
115118

@@ -324,10 +327,10 @@ public FileMapperOptions getMapperOptions(List<String> mappingParams, List<Strin
324327
}
325328

326329

327-
/** Checks that necessary oracle libraries exist
330+
/** Checks that ojdbc library exists
328331
*
329332
*/
330-
private void checkOracleLibrariesExist()
333+
private void checkOracleJDBCExists()
331334
{
332335
if ( !OracleLibraryChecker.checkOjdbcExists() )
333336
{
@@ -337,11 +340,17 @@ private void checkOracleLibrariesExist()
337340

338341
throw new RuntimeException("Can't run utPLSQL-cli without Oracle JDBC driver");
339342
}
343+
}
340344

341-
if ( !OracleLibraryChecker.checkOrai18nExists() )
345+
/** Checks that orai18n library exists if database is an oracle 11
346+
*
347+
*/
348+
private void checkOracleI18nExists(String oracleDatabaseVersion )
349+
{
350+
if ( oracleDatabaseVersion.startsWith("11.") && !OracleLibraryChecker.checkOrai18nExists() )
342351
{
343-
System.out.println("Warning: Could not find Oracle i18n driver in classpath. Depending on your database " +
344-
"version (11g) and used charset utPLSQL-cli might not run properly. It is recommended you download " +
352+
System.out.println("Warning: Could not find Oracle i18n driver in classpath. Depending on the database charset " +
353+
"utPLSQL-cli might not run properly. It is recommended you download " +
345354
"the i18n driver from the Oracle website and copy it to the 'lib' folder of your utPLSQL-cli installation.");
346355
System.out.println("Download from http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html");
347356
}

0 commit comments

Comments
 (0)