简体   繁体   中英

ORA-01017: invalid username/password; logon denied

I am using Oracle 11g with eclipse oxygen, i am trying to setup Jdbc connection, and i am using the connection statement

Connection con = DriverManager.getConnection("jdbc:oracle:thin:testuser/testuser@localhost");

I am sure that the username and password are right, but still i am getting

java.sql.SQLException: ORA-01017: invalid username/password; logon denied

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
    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:573)
    at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:431)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366)
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:752)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:366)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at JDBC.main(JDBC.java:12)

Could someone please help?

Maybe you can try using this snippet taken from JAVASE tutorial:

Connection conn = null;
Properties connectionProps = new Properties();
connectionProps.put("user", this.userName);
connectionProps.put("password", this.password);

if (this.dbms.equals("mysql")) {
    conn = DriverManager.getConnection(
               "jdbc:" + this.dbms + "://" +
               this.serverName +
               ":" + this.portNumber + "/",
               connectionProps);
} else if (this.dbms.equals("derby")) {
    conn = DriverManager.getConnection(
               "jdbc:" + this.dbms + ":" +
               this.dbName +
               ";create=true",
               connectionProps);
}
System.out.println("Connected to database");
return conn;

EDIT: Or maybe you can try to specify the user and the password like this:

Connection conn = DriverManager.getConnection("
     jdbc:oracle:thin:@localhost:1521:example", "example","password123");

You have a default case sensitive username and password in the database. It is necessary to type the username and password correctly in the case sensitive or change the parameter of the authentication of Oracle sec_case_sensitive_logon=false .

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> show parameter sec_case

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------------
sec_case_sensitive_logon             boolean     TRUE
SQL> alter system set sec_case_sensitive_logon=false scope=both;

System altered.

SQL> show parameter sec_case

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------------
sec_case_sensitive_logon             boolean     FALSE
SQL>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM