Remote Oracle database connection using java(netbeans)

时间:2018-06-04 16:41:23

标签: java oracle

This is the code that I use to connect with the Oracle database that is on my pc:

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection co = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:etecsa", "system", "asd");

It works but if I change localhost for an ip it can not connect to the database. I already deactivated the firewall but nothing.

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection co = DriverManager.getConnection("jdbc:oracle:thin:10.8.6.50:1521:etecsa", "system", "asd");

Where can I configure the oracle database to accept the connection from a specific ip and not only from localhost?

1 个答案:

答案 0 :(得分:0)

检查documentation for DB URL

  

JDBC:预言:driver_type:[用户名/密码] @database_specifier

所以在你的情况下(如果 etecsa SID),网址将为@host:port:SID

jdbc:oracle:thin:@10.8.6.50:1521:etecsa

如果 etecsa 是服务名称,请使用@//host:port/service_name

jdbc:oracle:thin:@//10.8.6.50:1521/etecsa