Oracle tnsping ok, spring Jdbctemplate TNS:Istener does not Currently know of SID Given in connect Descriptor

Asked

Viewed 243 times

0

I’m facing a problem, I hope you can help me, I am developing a web application running on Tomcat using Spring-mvc and data access with Jdbctemplate, the database is Oracle 11g. Within this scenario as of Prache, I have two environments, in the development environment everything works perfectly, access to data, pages etc. In production environment can not connect in the database in any way, testing by external tools (tnsping, Plsql) connects right, when I run Tomcat and try to access the page, I have the following error message:

ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

)] with root cause oracle.net.ns.Netexception: Listener refused the Connection with the following error: ORA-12505, TNS:Istener does not Currently know of SID Given in connect Descriptor at oracle.net.ns.NSProtocol.connect(Nsprotocol.java:399)

The settings and data access are saved in the context and in the server.xml of Tomcat, follow the list of settings:

xml context.

<ResourceLink name="jdbc/OracleDB"
                global="jdbc/OracleDB"
                auth="Container"
                type="javax.sql.DataSource" /> 

Server.xml within the Globalnamingresources node

<Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver"
        global="jdbc/OracleDB" maxActive="100" maxIdle="20" maxWait="10000"
        minIdle="5" name="jdbc/OracleDB" password="SGC" type="javax.sql.DataSource"
        url="jdbc:oracle:thin:@NB-ATROMBETONE:1521:xe" username="SGC" />

The above two settings are from the development environment, in the production environment I change only the attributes, url, username and password of Resource.

Already check firewall rules, lock doors, antivirus, but nothing solved. Does anyone have any suggestions or has been through it?

I appreciate any help.

  • the database is cataloged in the oracle Tnsnames on the machine where the deployment took place?

  • Hello friend, thanks for the iteration, answering your question, is yes, on the same pc I can test the connection by tnsping and Plsql, both work normally.

1 answer

1

problem solved. With the help of a professional in the database area, we find in the Oracle documentation (see link: https://docs.oracle.com/cd/B19306_01/java.102/b14355/jdbcthin.htm#i1004498) the solution.

Resolution: Run Tnsping with the desired SID. After obtaining a positive response from the test, take the TNSNAMES block that was used to solve the nickname. see image:

Print do retorno do tnsping

Right, now that you have the return, change the connection string by removing all the end part from the server hostname, then add the block that is highlighted in the image.

Before-> jdbc:oracle:thin:@NB-ATROMBETONE:1521:xe

Afterward-> jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = NB-ATROMBETONE)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))

Thank you all.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.