How to connect in java as SYS to Oracle?

user710818 picture user710818 · Apr 11, 2012 · Viewed 39.7k times · Source

I receive this error:

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

How to fix? (I need to be SYS). Thanks.

Answer

simplycurious picture simplycurious · Apr 11, 2012

try this :

import java.sql as jsql
import java.lang as lang
driver, url, user, passwd = (
"oracle.jdbc.driver.OracleDriver",
"jdbc:oracle:thin:@localhost:1234:xxx1",
"sys as sysdba",
"xxx1")
 lang.Class.forName(driver)
 c = jsql.DriverManager.getConnection(url,user,passwd)