File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
main/java/org/utplsql/sqldev/dal
test/java/org/utplsql/sqldev/tests Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1717
1818import java.sql.Connection
1919import java.util.List
20+ import org.springframework.dao.DataAccessException
2021import org.springframework.dao.EmptyResultDataAccessException
2122import org.springframework.jdbc.core.BeanPropertyRowMapper
2223import org.springframework.jdbc.core.JdbcTemplate
@@ -33,6 +34,20 @@ class UtplsqlDao {
3334 this . jdbcTemplate = new JdbcTemplate (new SingleConnectionDataSource (conn, true ))
3435 }
3536
37+ def boolean isDbaViewAccessible () {
38+ try {
39+ val sql = ' ' '
40+ SELECT 1
41+ FROM dba_objects
42+ WHERE 1=2
43+ ' ' '
44+ jdbcTemplate. execute(sql)
45+ return true
46+ } catch (DataAccessException e) {
47+ return false
48+ }
49+ }
50+
3651 /**
3752 * Gets the schema name of the utPLSQL installation.
3853 *
@@ -42,7 +57,7 @@ class UtplsqlDao {
4257 def String getUtplsqlSchema () {
4358 val sql = ' ' '
4459 SELECT table_owner
45- FROM all_synonyms
60+ FROM «IF dbaViewAccessible»dba«ELSE»all«ENDIF»_synonyms
4661 WHERE owner = ' PUBLIC '
4762 AND synonym_name = ' «UTPLSQL_PACKAGE_NAME »'
4863 AND table_name = ' «UTPLSQL_PACKAGE_NAME »'
Original file line number Diff line number Diff line change @@ -35,7 +35,15 @@ class DalTest extends AbstractJdbcTest {
3535 } catch (BadSqlGrammarException e) {
3636 // ignore
3737 }
38- }
38+ }
39+
40+ @Test
41+ def void isDbaViewAccessible () {
42+ val dao = new UtplsqlDao (dataSource. connection)
43+ Assert . assertFalse(dao. dbaViewAccessible)
44+ val sysDao = new UtplsqlDao (sysDataSource. connection)
45+ Assert . assertTrue(sysDao. dbaViewAccessible)
46+ }
3947
4048 @Test
4149 def void utplsqlSchema () {
You can’t perform that action at this time.
0 commit comments