Java – unable to connect to Oracle using spring boot and Hibernate
I have a spring boot application using Postgres (1.2) Today, I was trying to switch it to Oracle, but when I tried to connect, I got an exception saying:
java.sql.sqlRecoverableException: IO Error: The Network Adapter Could not establish the connection
Under that,
Caused by: java.net.ConnectException: Connection refused
Of course, this looks like bad credentials, but I know they're good, and they work well in Oracle SQL developer I'm confused This is my properties file entry:
# Properties for Hibernate and Oracle spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver spring.datasource.url=jdbc:oracle:thin:@//earth-db-11:5121/stardev spring.datasource.username=ops$abcdefg spring.datasource.password=mypassword spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
My only idea is that there is a $, I try to escape it and put double quotes around it
Any ideas?
Thank you
to update:
Thank you very much bonanzaone. My port number is wrong Corrections will result in new errors:
java.sql.sqlRecoverableException: Listener refused the connection with the following error: ORA-12514,TNS:listener does not currently kNow of service requested in connect descriptor
Of course, I checked, but I didn't follow what it told me:
ORA-12514: TNS:listener does not currently kNow of service requested in connect descriptor Cause: The listener received a request to establish a connection to a database or other service. The connect descriptor received by the listener specified a service name for a service (usually a database service) that either has not yet dynamically registered with the listener or has not been statically configured for the listener. This may be a temporary condition such as after the listener has started,but before the database instance has registered with the listener.
However, the SQL Explorer connection is normal
Solution
This exception means that the Oracle listener is not started, or you are trying to connect to a listener that does not exist / is not accessible
My guess is that you tried the wrong port "5121" The default Oracle port is 1521
You can try and see what happens?
Starting from FAQ, there are basically two methods to form JDBC string URL:
My guess is that you use the wrong syntax - SID / service name combination. In other words, you use the new syntax that requires the service name, but you use the SID name to execute it
Try this: JDBC: Oracle: thin: @ earth-db-11:1521: stardev
Or find the service name and apply it to the new syntax you are using instead of the SID name