0

I am using an application which needs to access my oracle database to do some tasks with my data.

That application needs two properties, which are:

d2rq:jdbcDSN

The JDBC database URL. This is a string of the form jdbc:subprotocol:subname. For a MySQL database, this is something like jdbc:mysql://hostname:port/dbname. Examples for other databases #

d2rq:jdbcDriver

The JDBC driver class name for the database. Used together with d2rq:jdbcDSN. Example: com.mysql.jdbc.Driver for MySQL. #

I want to connect to an Oracle database that has this version

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
"CORE   11.2.0.4.0  Production"
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

Normally I connect to my oracle database using a SQL developer application where I just set:

  1. Host Name
  2. Username and password
  3. Service Name
  4. Schema

Now to connect to my database from this new app (now the sql developer), i am required to do (from this page http://www.devx.com/tips/Tip/28818)

jdbc:oracle:thin:@<HOST>:<PORT>:<SID>
oracle.jdbc.driver.OracleDriver

so I changed that template to:

jdbc:oracle:think:@HostName:port:ServiceName

and I copied the ojdbc6.jar to the bin folder

when I run, i get this error:

Database connection to jdbc:oracle:thin:@HostName:Porto:ServiceName failed (user: UserName): Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect description

It sounds like the SID should be be replaced by service name. (i am not sure) do you have any idea about how to solve it and if what I did is correct?

off course i hide the real database and host and password for privacy reasons so please execuse me

Ania David
  • 1,168
  • 1
  • 15
  • 36
  • Problem is on server side. You are calling an SID that the listener does not recognize as an existing service. Check your conn params. – Alfabravo Apr 22 '16 at 13:57
  • AFAIK you are supposed to use _oracle.jdbc.OracleDriver_ now _oracle.jdbc.driver.OracleDriver_ is deprecated – Nicolas Filotto Apr 22 '16 at 14:00
  • @Alfabravo so you are saying that SID is the same as service name, right? then how can I connect successfuly from sql developer? – Ania David Apr 22 '16 at 14:07

1 Answers1

2

I found the error

it should be like this

jdbc:oracle:thin:@hostname:porto/servicename

not

jdbc:oracle:thin:@hostname:porto:servicename

Ania David
  • 1,168
  • 1
  • 15
  • 36