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)
/*It works for me*/
/*also oci and thin is important if you want to connect with database which is installed in your clien (Computer) add oci if you want to install to server add thin*/
String dbURL2 = "jdbc:oracle:oci:@172.16.24.123:1521:XE";
String username = "sys as sysdba";
String password = "XX Change it to your system password";
try {
Connection connection = DriverManager.getConnection(dbURL2, username, password);
System.out.println("Connected to Oracle data");
} catch (SQLException e) {
System.out.println("Opps ! error");
e.printStackTrace();
}
9条答案
按热度按时间9wbgstp71#
试试这个:
tez616oj2#
答案已经在那里了,
您正在尝试以
sys
身份连接,但服务器允许要么
或
只需将用户参数更改为上面的任意一个
或
toiithl63#
这段代码有效
pgccezyw4#
如果您尝试像这样连接到数据库:
connect SYS/<password>
您使用了不再有效的语法(Oracle 9i之后)。请尝试按以下方式连接:
x33g5p2x5#
您是否能够使用OracleDataSource对象?
然后这样称呼它:
zd287kbt6#
如果你想连接你的数据库与用户以外的“sys”作为“sysdba”那么你必须改变驱动程序从“瘦”到“oci”使成功的连接.
dy2hfwbg7#
rlcwz9us8#
您需要将sysdba与user String参数一起放置,如
anauzrmj9#
我的两分钱,因为我遇到了同样的例外。以下为我做的把戏: