Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

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?

like image 405
Aniket Thakur Avatar asked Apr 06 '15 18:04

Aniket Thakur


1 Answers

The following does work. 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)
like image 175
Jayan Avatar answered Sep 28 '22 08:09

Jayan