oracle 在 groovy 中获取“java.sql.SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29476997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting "java.sql.SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER" in groovy
提问by Aniket Thakur
Code is as follows -
代码如下——
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)
But I am getting following error
但我收到以下错误
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)
I tried replacing user as 'sys as sysdba' as mentioned in this SO answer.
我尝试将用户替换为 'sys as sysdba',如这个 SO answer 中所述。
I also tried using
我也尝试使用
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)
as suggested here
正如这里所建议的
but here I am getting
但在这里我得到
Caused by: java.sql.SQLException: ORA-01017: invalid username/password; logon denied
Any suggestions?
有什么建议?
回答by Jayan
The following doeswork. Only difference is the driver name
以下确实有效。唯一的区别是驱动程序名称
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)