Error connecting to Oracle DB from Java - oracle

Could someone please help me on why I received the following error while trying to connect to Oracle db from java....
The connection call is:
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:#winson.net:1522/hcrod",
"manager", "passing");
I receive the following error:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:389)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:454)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:802)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at test_sample.main(test_sample.java:15)

in a similar case for me worked a slightly other connect string:
jdbc:oracle:thin:#winson.net:1522:hcrod
really without the // and with : instead of /

I've seen this error come up a few times when I've started the TNS listener after I started the database. When the database starts up it registers itself with the listener if the listener is running, but if the listener isn't running it can't do this.
It's possible to manually persuade the database to register itself with the listener. To do this, connect to the database as SYS and run the SQL statement ALTER SYSTEM REGISTER;.

It sounds like the port on the server isn't listening, port 1522.
Can you telnet the port successfully?

Oracle's JDBC thin URI syntax is as follows:
jdbc:oracle:thin:[USER/PASSWORD]#//[HOST][:PORT]/SERVICE
So:
jdbc:oracle:thin:#//winson.net:1522/hcrod"
Note the two slashes added after the # symbol.

i think port number for oracle is 1521

Related

How to fix IO Error: The Network Adapter could not establish the connection

I am trying to connect my oracle cloud database using sqldeveloper with connection type basic but it fails connection with error:
Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection.
Anyone can help how can i connect my oracle db system using sqldevloper with connection type either basic or TNS ??
Have you tried to telnet the server on port 1521?
It sounds likely that the dbsystem is not connected to the internet.
Please check if the dbsystem subnet has:
Security List with a rule to allow port 1521 on your ip address
Routing Table that allows internet access via internet gateway

DB Link throws ORA-28511: lost RPC connection to heterogeneous remote agent using SID

I use a DBLINK/Oracle Gateway to connect to an external non-oracle database. i have a timeout setting of 5 minutes.
when I connect using dblink, for the first time, it runs fine. After the idle time of 5 minutes, when I run the same sql again, it throws me the bellow error -
ORA-28511: lost RPC connection to heterogeneous remote agent using SID. ****
ORA-28509: unable to establish a connection to non-Oracle system
ORA-02063: preceding line from DB2T
Then when i run the sql again, its connecting fine. i guess its establishing a new connection.
Why am i getting the connection error and why oracle is not simply establishing a new connection when the previous connection is timed out?
Is there a way to not get the error and connect seamlessly or to suppress the error?
Easily replicable in sql developer by running a sql and waiting for 5 minutes.
Thanks in Advance.

JDBC connection error for HIVE while using SQL WorkbenchJ

I am trying to establish a JDBC connection to access HIVE via SQL workbenchJ. I have placed all the JARs needed for connection along with the connection URL. Am getting the error
[Amazon]HivejdbcDriver error initialized or created
transport for authentication:null
while testing the connection. Can anyone help me on this?

Oracle listener create logon

I would like to prepare listner in another port but I have got problems you can see this in picture with I added below. Also I would like to connect to dabase using this "listener" and check connection in CMD using easy connect.
My username: rafal password:oracle
listener in 1521 is working but in another port I have got problem
"No listener" error indicates either that you're reaching the wrong server, or the right server on the wrong port, or that the listener is not started. I would start by checking that the listener is started, since you can reach the other one.

Oracle connection error

java.sql.SQLException: Io exception: The Network Adapter could not establish the
connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java)
I am getting this error when data in database is increased (nearly 3000). It works fine with limited data (say 100).
The Network Adapter could not establish the connection
Is typically thrown when
the Oracle listener is not running
the wrong hostname was specified in the connection url
the wrong port was specified in the connection url
the port is blocked by firewall
I have never seen it related to "increasing" the data in the database

Resources