Skip to content

Commit

Permalink
Merge pull request #68 from PhilippSalvisberg/feature/issue_64_no_utp…
Browse files Browse the repository at this point in the history
…lsql

#64 - Improve error handling when no utPLSQL is installed
  • Loading branch information
PhilippSalvisberg committed Jul 13, 2019
2 parents 503c5b1 + 66be251 commit e8130c6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sqldev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- The Basics -->
<groupId>org.utplsql</groupId>
<artifactId>org.utplsql.sqldev</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
36 changes: 22 additions & 14 deletions sqldev/src/main/java/org/utplsql/sqldev/dal/UtplsqlDao.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.utplsql.sqldev.model.ut.OutputLines

class UtplsqlDao {
public static val UTPLSQL_PACKAGE_NAME = "UT"
public static val NOT_INSTALLED = 0000000
public static val FIRST_VERSION_WITH_INTERNAL_ANNOTATION_API = 3000004
public static val FIRST_VERSION_WITH_ANNOTATION_API = 3001003
public static val FIRST_VERSION_WITHOUT_INTERNAL_API = 3001008
Expand Down Expand Up @@ -60,14 +61,15 @@ class UtplsqlDao {
* returns a normalized utPLSQL version in format 9.9.9
*/
def String normalizedUtPlsqlVersion() {
val p = Pattern.compile("(\\d+\\.\\d+\\.\\d+)")
val version = getUtPlsqlVersion()
val m = p.matcher(version)
if (m.find) {
return m.group(0)
} else {
return "0.0.0"
if (version !== null) {
val p = Pattern.compile("(\\d+\\.\\d+\\.\\d+)")
val m = p.matcher(version)
if (m.find) {
return m.group(0)
}
}
return "0.0.0"
}

/**
Expand Down Expand Up @@ -97,14 +99,20 @@ class UtplsqlDao {
? := ut.version;
END;
'''
cachedUtPlsqlVersion = jdbcTemplate.execute(sql, new CallableStatementCallback<String>() {
override String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
cs.registerOutParameter(1, Types.VARCHAR);
cs.execute
val version = cs.getString(1)
return version
}
})
try {
cachedUtPlsqlVersion = jdbcTemplate.execute(sql, new CallableStatementCallback<String>() {
override String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
cs.registerOutParameter(1, Types.VARCHAR);
cs.execute
val version = cs.getString(1)
return version
}
})
} catch (SQLException e) {
// ignore error
} catch (DataAccessException e) {
// ignore error
}
}
return cachedUtPlsqlVersion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,5 +588,12 @@ class DalTest extends AbstractJdbcTest {
Assert.assertEquals("PACKAGE", actual)
jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
}

@Test
def void normalizedUtPlsqlVersion() {
val dao = new UtplsqlDao(dataSource.connection)
val version = dao.normalizedUtPlsqlVersion
Assert.assertTrue(version !== null)
}

}

0 comments on commit e8130c6

Please sign in to comment.