获取" java.sql.SQLException:ORA-28009:作为SYS的连接应该是SYSDBA或SYSOPER"在groovy

时间:2015-04-06 18:14:52

标签: java oracle groovy sysdba

代码如下 -

import groovy.sql.Sql

def driver = "oracle.jdbc.OracleDriver"
def jdbcUrl = "jdbc:oracle:thin@myhost:1521:MYSID"
def sql = Sql.newInstance(jdbcUrl , "sys", "password", driver)

但我收到了以下错误

Caught: java.sql.SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

java.sql.SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
        at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:600)
        at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:445)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:380)
        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:760)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:401)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)

我尝试将用户替换为'{s}作为sysdba',如this SO answer中所述。

我也尝试过使用

Properties props = new Properties()
props.put("user","sys")
props.put("password", "password")
props.put("internal_logon", "sysdba")
jdbcUrl = "jdbc:oracle:thin@myhost:1521:MYSID"
def sql=Sql.newInstance(jdbcUrl,props)

建议here

但是我在这里

Caused by: java.sql.SQLException: ORA-01017: invalid username/password; logon denied

有什么建议吗?

1 个答案:

答案 0 :(得分:9)

以下确实有效。唯一的区别是驱动程序名称

import groovy.sql.Sql

def driver = "oracle.jdbc.driver.OracleDriver"
def jdbcUrl = "jdbc:oracle:thin:@oraclehost:1521:SID"
def sql = Sql.newInstance(jdbcUrl , "sys as sysdba", "syspassword", driver)