I'm trying to connect to a database which is hosted in a remote machine. I have a java project in my local and it has to connect to DB which is in remote machine for an update. What is the java code which I can use to connect. Traditional code of connection doesn't work and it shows below error.
import java.beans.Statement;
import java.sql.*;
public class connectTest {
public static void main(String[] args) {
try{
//step1 load the driver class
Class.forName("oracle.jdbc.driver.OracleDriver");
// Class.forName("oracle.jdbc.OracleDriver");
Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@172.25.250.183:1521/aaadv4","boomerang","Telus2014");
Wrapper stmt=con.createStatement();
ResultSet rs=((java.sql.Statement) stmt).executeQuery("select * from ttv_dhcp_log.ACCT_MSG where SUB_IF='BACUPQXQOT01 PON 1/1/12/02:21.1.1'");
while(rs.next())
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3));
//step5 close the connection object
con.close();
}catch(Exception e){ System.out.println(e);}
}
}
I expect it to connect to DB but it fails with below message.
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection