1

I have been trying to connect to this Oracle database with JDBC thin driver with the following syntax:

var URL = "jdbc:oracle:thin:@//16.161.286.56:1522/Service_Name"; 
var USER = "user";
var PASS = "password";
var conn = Jdbc.getConnection(URL, USER, PASS);

I keep on having the same response when I execute this:

We're sorry, a server error occurred. Please wait a bit and try again. [87a99af]

Would anyone have an idea of what I am doing wrong ?


Also, when I change the IP address to its 'string version':

var URL = "jdbc:oracle:thin:@//mydomain.com:1522/Service_Name";

Then I get the error response:

Failed to establish a database connection. Check connection string, username and password.

Which does not make sense to me as both expressions are supposed to be equivalent ...

Daniel Weigel
  • 1,097
  • 2
  • 8
  • 14
  • 1
    Do you have any stacktraces / sql error codes you can add? Also make sure that the domain can actually be resolved. – second Jul 30 '19 at 05:07
  • Related: https://stackoverflow.com/questions/4832056/java-jdbc-how-to-connect-to-oracle-using-service-name-instead-of-sid?rq=1 – Mark Rotteveel Jul 30 '19 at 10:08
  • Hi @MarkRotteveel thanks for the answer. I stumbled upon this question before asking mine. I figured that maybe I get a server error because the Oracle server I am trying to connect with may not have Google scripts IP ranges whitelisted..... I will explore that solution today. Still, I do not understand why changing the domain name by its IP address number version gives me a different response – Daniel Weigel Jul 30 '19 at 23:23

3 Answers3

1

The actual format of Oracle JDBC connection using service name is:

@//host_name:port_number/service_name

Make sure that is service name is ok. You can try with TNSNameListener

jdbc:oracle:thin:@(description=(address=(host=<HOSTADDRESS>)(protocol=tcp)(port=<PORT>))(connect_data=(service_name=<SERVICENAME>)(server=<SHARED>)))

The TNSNameListener file location:

<ORACLE_HOME>\network\admin\tnsnames.ora
example: /home/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
0

I am not sure which class is that Jdbc is. Take a look at the JDBCUrlSample.java and DataSourceSample.java

Nirmala
  • 1,278
  • 1
  • 10
  • 11
0

Use this:

jdbc:oracle:thin:@//hostname:1521/ServiceName

Vishnu Mari
  • 136
  • 1
  • 6