Database

Get Involved. Join the Conversation.

Topic

    Karthik Varma
    How to connect to Autonomous Database from Java Application?
    Topic posted October 15, 2019 by Karthik VarmaGold Medal: 3,500+ Points, tagged Doc, Monitoring, SQL Dev Web 
    33 Views, 1 Comment
    Title:
    How to connect to Autonomous Database from Java Application?
    Content:

    I have referred this article https://docs.oracle.com/en/cloud/paas/atp-cloud/atpug/connect-preparing.html#GUID-3667EC68-930E-4566-95B3-DFA24203A8FF.

    Referred Sample from github: https://github.com/oracle/oracle-db-examples/blob/master/java/jdbc/ConnectionSamples/DataSourceSample.java

    Set the environmental variable TS_ADMIN to ''E:\Oracle Cloud Learnings\Oracle ATP credentials" (This is the directory where my wallet files are located)

    JDK version : 1.8.0_202

    Code:

      final static String DB_URL="jdbc:oracle:thin:@dbtransprocess_tpurgent?TNS_ADMIN=E://Oracle Cloud Learnings//Oracle ATP credentials";
      final static String DB_USER = "XYZ";
      final static String DB_PASSWORD = "abcd";

    Error:

    Exception in thread "main" java.sql.SQLRecoverableException: IO Error: could not resolve the connect identifier  "dbtransprocess_tpurgent"

    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:854)
    at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747)
    at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:406)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:291)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:206)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:184)
    at com.zoho.listeners.DataSourceSample.main(DataSourceSample.java:68)
    I am getting the above error. Any suggestions or anything i missed out? Appreciate your help.
     
    Please let me know, if there is any other way connecting to Autonomous database.
    Image:

    Comment

     

    • Simon Law

      Can you try and use the URL referenced in the DataSourceSample.java and see if it helps?

      // In case of windows, use the following URL

      // final static String DB_URL="jdbc:oracle:thin:@wallet_dbname?TNS_ADMIN=C:\\Users\\test\\wallet_dbname