Eclipse-plsql连接oracle正常但javajdbc连不上(java.sql.SQLException: ORA-01017: invalid username/password; logon denied)

1、错误现象

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

    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:406)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
    at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:799)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:368)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at Test.getConnection(Test.java:76)
    at Test.download(Test.java:22)
    at Test.main(Test.java:14)
Exception in thread "main" java.lang.NullPointerException
null    at Test.download(Test.java:58)
    at Test.main(Test.java:14)

二、原因

PL/SQL使用的是SERVICE_NAME连接,程序里用了SID连接

三、本次解决方法

两种程序中的连接方法:

SID连接方式:

jdbc:oracle:thin:@<host>:<port>:<SID>

SERVICE_NAME连接方式:

jdbc:oracle:thin:@<host>:<port>/ServiceName

 

posted @ 2020-09-28 10:36  cqyyck  阅读(1353)  评论(0编辑  收藏  举报