[英]Can't start sql db in 11g through jdbc.Getting java sql exception
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? 有人能帮忙吗?
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 通过执行以下命令,检查侦听器当前知道哪些服务: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. 检查所使用的网络服务名称的连接描述符中的SERVICE_NAME参数是否指定了侦听器已知的服务。
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. 在listener.log文件中检查事件。
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, 您必须了解,在谈到异常时,很多时候JDBC只是充当DB发生的错误的包装,
or propagates driver specific (ie - postgresql jdbc driver, oracle jdbc driver) specific errors. 或传播特定于驱动程序的错误(即-postgresql jdbc驱动程序,oracle jdbc驱动程序)。
You should google the error and you will find what I believe is a clear explanation: 您应该在Google上搜索该错误,然后您会发现我认为这是一个明确的解释:
http://ora-12514.ora-code.com/ . http://ora-12514.ora-code.com/ 。
If you see one of the suggestions there is to retry after a few seconds and reconnect again. 如果您看到其中一项建议,请在几秒钟后重试,然后重新连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.