Connect Oracle cloud DB in JAVA using SSH with Local port forward


April 2019


250 time


I want to connect to an Oracle db in JAVA which hosted in cloud. I have server private key and remote details to connect.

I can establish SSH connection to server with private key authentication and created SSH tunnel. Now using this tunnel, I can connect to remote server and forwarded session to local port.

Now I used below URL to connect Oracle DB,

"jdbc:oracle:thin:@//localhost:" + local_port_forward + "/service_name", db_user, db_password

But it throws below error:

java.sql.SQLException: Oracle Error: ORA-12650

1 answers


The Oracle server may redirect the client (JDBC thin in your example) to a different port than the listener's port. So doing Oracle database connection over an SSH tunnel isn't possible.