Skip to content

Commit e8130c6

Browse files
Merge pull request #68 from PhilippSalvisberg/feature/issue_64_no_utplsql
#64 - Improve error handling when no utPLSQL is installed
2 parents 503c5b1 + 66be251 commit e8130c6

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

sqldev/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<!-- The Basics -->
66
<groupId>org.utplsql</groupId>
77
<artifactId>org.utplsql.sqldev</artifactId>
8-
<version>1.0.0</version>
8+
<version>1.1.0-SNAPSHOT</version>
99
<packaging>bundle</packaging>
1010
<properties>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.xtend

+22-14
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import org.utplsql.sqldev.model.ut.OutputLines
3333

3434
class UtplsqlDao {
3535
public static val UTPLSQL_PACKAGE_NAME = "UT"
36+
public static val NOT_INSTALLED = 0000000
3637
public static val FIRST_VERSION_WITH_INTERNAL_ANNOTATION_API = 3000004
3738
public static val FIRST_VERSION_WITH_ANNOTATION_API = 3001003
3839
public static val FIRST_VERSION_WITHOUT_INTERNAL_API = 3001008
@@ -60,14 +61,15 @@ class UtplsqlDao {
6061
* returns a normalized utPLSQL version in format 9.9.9
6162
*/
6263
def String normalizedUtPlsqlVersion() {
63-
val p = Pattern.compile("(\\d+\\.\\d+\\.\\d+)")
6464
val version = getUtPlsqlVersion()
65-
val m = p.matcher(version)
66-
if (m.find) {
67-
return m.group(0)
68-
} else {
69-
return "0.0.0"
65+
if (version !== null) {
66+
val p = Pattern.compile("(\\d+\\.\\d+\\.\\d+)")
67+
val m = p.matcher(version)
68+
if (m.find) {
69+
return m.group(0)
70+
}
7071
}
72+
return "0.0.0"
7173
}
7274

7375
/**
@@ -97,14 +99,20 @@ class UtplsqlDao {
9799
? := ut.version;
98100
END;
99101
'''
100-
cachedUtPlsqlVersion = jdbcTemplate.execute(sql, new CallableStatementCallback<String>() {
101-
override String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
102-
cs.registerOutParameter(1, Types.VARCHAR);
103-
cs.execute
104-
val version = cs.getString(1)
105-
return version
106-
}
107-
})
102+
try {
103+
cachedUtPlsqlVersion = jdbcTemplate.execute(sql, new CallableStatementCallback<String>() {
104+
override String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
105+
cs.registerOutParameter(1, Types.VARCHAR);
106+
cs.execute
107+
val version = cs.getString(1)
108+
return version
109+
}
110+
})
111+
} catch (SQLException e) {
112+
// ignore error
113+
} catch (DataAccessException e) {
114+
// ignore error
115+
}
108116
}
109117
return cachedUtPlsqlVersion
110118
}

sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalTest.xtend

+7
Original file line numberDiff line numberDiff line change
@@ -588,5 +588,12 @@ class DalTest extends AbstractJdbcTest {
588588
Assert.assertEquals("PACKAGE", actual)
589589
jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
590590
}
591+
592+
@Test
593+
def void normalizedUtPlsqlVersion() {
594+
val dao = new UtplsqlDao(dataSource.connection)
595+
val version = dao.normalizedUtPlsqlVersion
596+
Assert.assertTrue(version !== null)
597+
}
591598

592599
}

0 commit comments

Comments
 (0)