我可以使用凭据(用户名:HR,密码:*****)。但我收到错误消息
ORA-28000:帐户被锁定
当我尝试使用JDBC从Java程序建立连接时,会出现这种情况。
编码:
public static void main(String args[]) throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
Connection con = DriverManager.getConnection(url,"USER NAME","PASSWORD");
Statement statement = con.createStatement();
ResultSet resultset = statement.executeQuery("select 'Connected' from dual");
while (resultset.next()) {
System.out.println(resultset.getString(1));
}
statement.close();
con.close();
}
如何从这个java程序连接到数据库?
2条答案
按热度按时间gudnpqoy1#
When connect using the credentials (Username : system, Password : ####) the account got connected without any issue from java program. However, when connected using the credentials (Username: HR, Password : ****) got the error message ORA-28000: the account got locked. But was able to login using these HR credentials from oracle console. So, to get the connection from java program, did the following:
The HR account got unlocked and now able to execute other queries without issues :)
bwleehnv2#
只需将用户名更改为“System”而不是“HR”即可!您现在就可以连接到数据库了。