日期:2014-05-16  浏览次数:20426 次

java 用jdbc方式以 sys账号连接oracle数据的问题

jdbc.properties
driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
username=sys
password=password


报错:
Exception in thread "main" java.sql.SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER



改成

username=sys as sysdba

  就可以连接了!


如果是PL/SQL的话直接sys/rebeyond as sysdba就可以了。

    其实在java的连接字符串里,只要把String user="sys"改成String user="sys as sysdba"就可以改变默认的Normal登陆模式了。


  Connection c = DriverManager.getConnection(url, "sys as sysdba",
     "password");