0

I've been trying to setup remote connection for a while now using the database host ip address in my java application in order to connect remotely and send it SQL queries. Here is the method I'm using to setup connection:

public static Connection openCon ()
{
    try {
        //load the driver class
        Class.forName("oracle.jdbc.driver.OracleDriver");

        String url = "jdbc:oracle:thin:@192.168.1.24:1521/orclpdb";
        String user = "TAGCOMPDBA";
        String pass = "minigrr1";

        //create the connection object
        Connection con = DriverManager.getConnection(url, user, pass);
        System.out.println("Connection made to PDB");
        return con;
        }
    catch(Exception e) {
        System.out.print(e);
        return null;
    }
}

When I run my program this error is given:

java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection

I've attempted editing my listener.ora to add my ip address as an address. I also edited my tnsnames.ora to have an entry with my ip address as the host and I made sure my firewall was not blocking the port. None of this has worked and I have no idea where to go from here. Perhaps I'm not understanding something?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Chris G
  • 1
  • 1
  • have you checked if listener has started ? – Satya Nov 27 '19 at 02:20
  • Are you able to connect to the database from the machine which hosts the java program using any other client tools such as sqldeveloper or TOAD successfully – George Joseph Nov 27 '19 at 02:32
  • I am able to connect locally yes, sqldeveloper works without any issues connecting to the database locally – Chris G Nov 27 '19 at 22:42
  • Right now I'm trying an approach with a java server that makes the queries on my local machine and then a client which connects and sends sql strings using sockets. – Chris G Nov 27 '19 at 22:44

0 Answers0