简体   繁体   中英

Remote Oracle database connection using java(netbeans)

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?

Check the documentation for DB URL

jdbc:oracle:driver_type:[username/password]@database_specifier

so in your case (if etecsa is SID ) the url will be @host:port:SID

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

if etecsa is a service name then use @//host:port/service_name

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM