在 groovy 中获得 "java.sql.SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER"
Getting "java.sql.SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER" in groovy
代码如下-
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)
我尝试将用户替换为 'sys as 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
有什么建议吗?
以下确实有效。唯一不同的是驱动程序名称
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)
代码如下-
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)
我尝试将用户替换为 'sys as 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
有什么建议吗?
以下确实有效。唯一不同的是驱动程序名称
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)