问题描述
Connectionconn=DriverManager.getConnection("jdbc:oracle:thin:"+"@localhost:1521:orcl","scott","1123");请各位大哥哥们给指点下,我是新手!!我用java操作时:出现的错误如下:java.sql.SQLException:Listenerrefusedtheconnectionwiththefollowingerror:ORA-12505,TNS:listenerdoesnotcurrentlyknowofSIDgiveninconnectdescriptorTheConnectiondescriptorusedbytheclientwas:localhost:1521:orclatoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)atoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:280)atoracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:319)atoracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:344)atoracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:148)atoracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)atoracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)atjava.sql.DriverManager.getConnection(DriverManager.java:525)atjava.sql.DriverManager.getConnection(DriverManager.java:171)atcom.dp.day01.Base.test(Base.java:23)atcom.dp.day01.Base.main(Base.java:12)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:585)atorg.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:79]
解决方案
解决方案二:
用ip连接吧。先看看监听的ip是多少
解决方案三:
你的用户名称和密码是否正确
解决方案四:
ding
解决方案五:
ding
解决方案六:
用ip连接是如下的错误啊!!!java.sql.SQLException:Io异常:TheNetworkAdaptercouldnotestablishtheconnectionatoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)atoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)atoracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:274)atoracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:319)atoracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:344)atoracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:148)atoracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)atoracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)atjava.sql.DriverManager.getConnection(DriverManager.java:525)atjava.sql.DriverManager.getConnection(DriverManager.java:171)atcom.dp.day01.Base.test(Base.java:23)atcom.dp.day01.Base.main(Base.java:12)
解决方案七:
很明显呀,你连接数据库的ip是错误的,都找不到。仔细检查一下你的orcale配置的ip,修改了就可以了。
解决方案八:
localhost换成你数据库的host(如:HOST=172.20.1.5)
解决方案九:
检查你的IP和Oracle数据库的SID是否正确~~~
解决方案十:
up
解决方案十一:
把localhost改成ip,然后检查sid是否正确
解决方案十二:
Connectioncon=DriverManager.getConnection("jdbc:odbc:ora","scott","tiger");用这个实时看
解决方案十三:
Class.forName("oracle.jdbc.driver.OracleDriver");conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:数据库名称","用户名","密码");
解决方案十四:
用hierbneat
解决方案十五:
你的Sql语句写的有问题吧
解决方案:
在你指定的ip下没有找到那个sid
解决方案:
DriverManager.getConnection("jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL",sUsr,sPwd);
解决方案:
你先确定你是否打开了ORACLE的服务和他的监听两个服务如果打开了那么这就是ORACLE安装的问题ORACLE安装的时候如果是连网的那么以后你在启动服务的时候IP必须和装机时的IP一致才可行要么你不连网装ORACLE,那么以后你启动ORACLE的时候也不连网启动ORACLE