1
import java.sql.SQLException;
import oracle.jdbc.pool.OracleDataSource;
import java.sql.Statement;
import java.util.Properties;
import oracle.jdbc.OracleConnection;

public class Test {

static final String url2= "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP 

(HOST=192.168.1.171)(PORT=5521))"+"(CONNECT_DATA =(SERVICE_NAME = rdbms)))";

public static void main(String[] args) throws SQLException {

            OracleDataSource ds = new OracleDataSource();
           Properties prop = new Properties();
           prop.setProperty("user","system");
           prop.setProperty("password","manager");
           prop.setProperty("internal_logon","sysdba");
           prop.setProperty("prelim_auth","true");
           ds.setConnectionProperties(prop);
           ds.setURL(url2);
           OracleConnection conn = (OracleConnection)ds.getConnection();
           conn.startup(OracleConnection.DatabaseStartupMode.NO_RESTRICTION);
           conn.close();
    }
}

getting

Exception in thread "main" 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

Can anyone help with this?

2 Answers 2

1

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.

Action: - Wait a moment and try to connect a second time.

  • Check which services are currently known by the listener by executing: lsnrctl services

  • Check that the SERVICE_NAME parameter in the connect descriptor of the net service name used specifies a service known by the listener.

  • If an easy connect naming connect identifier was used, check that the service name specified is a service known by the listener.

  • Check for an event in the listener.log file.

Sign up to request clarification or add additional context in comments.

Comments

0

You must understand that when it comes to exceptions, many times JDBC simply serves as a wrapper to errors that occur at the DB side,
or propagates driver specific (i.e - postgresql jdbc driver, oracle jdbc driver) specific errors.
You should google the error and you will find what I believe is a clear explanation:
http://ora-12514.ora-code.com/.
If you see one of the suggestions there is to retry after a few seconds and reconnect again.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.