The Network Adapter could not establish the connection at oracle.jdbc.driver.T4CConnection.logon
来源:互联网 发布:国云数据裁员 编辑:程序博客网 时间:2024/06/06 19:31
学习马士兵视频的时候,学到JDBC的部分,首先不需要下载那个lomboz,那个官网都不更新,过时了,我直接用的是Mars版本的Eclipse,好像已经直接集成了!按照视频中的马士兵老师写的代码写,但是会报错!
import java.sql.*;public class TestJDBC { public static void main(String[] args) throws Exception{ //load the Driver Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.1:1521:orcl", "scott", "tiger"); System.out.println("llllllllll"); }}
后面给的输出是为了显示已经连接上或者没连接上,有的机器慢,运行了半天才给出Exception。
Exception in thread "main" java.sql.SQLException: The Network Adapter could not establish the connection at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503) at java.sql.DriverManager.getConnection(DriverManager.java:571) at java.sql.DriverManager.getConnection(DriverManager.java:215) at TestJDBC.main(TestJDBC.java:8)Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:359) at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:422) at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:672) at oracle.net.ns.NSProtocol.connect(NSProtocol.java:237) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301) ... 7 moreCaused by: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:141) at oracle.net.nt.ConnOption.connect(ConnOption.java:123) at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:337) ... 12 more
后来查网上有说是IP地址错的,有说是用户名、密码错的,但是把168.0.0.1改成127.0.0.1,也没行。
最后找到一个答案说是oracle的监听器没打开
两个结合果然连上了!
所以首先把监听器打开,然后把IP地址改成127.0.0.1应该就行了
2 0
- The Network Adapter could not establish the connection at oracle.jdbc.driver.T4CConnection.logon
- Oracle the network adapter could not establish the connection 异常
- Oracle the network adapter could not establish the connection
- oracle The Network Adapter could not establish the connection
- Oracle the network adapter could not establish the connection
- Oracle the network adapter could not establish the connection
- Oracle the network adapter could not establish the connection
- 解决:Oracle the network adapter could not establish the connection
- The Network Adapter could not establish the connection;The Network Adapter could not establish the c
- oracle 11g JDBC连接数据库:IO异常The Network Adapter could not establish the connection 解决方法
- Io 异常: The Network Adapter could not establish the connection
- Io 异常: The Network Adapter could not establish the connection
- Io 异常: The Network Adapter could not establish the connection
- Io 异常: The Network Adapter could not establish the connection
- Io 异常: The Network Adapter could not establish the connection
- The Network Adapter could not establish the connection
- Io 异常: The Network Adapter could not establish the connection
- The Network Adapter could not establish the connection
- Shell - 6
- String类型的相关类
- 【bzoj2588】Spoj 10628. Count on a tree LCA+主席树
- 局部变量的默认值是什么?默认值在Debug版本和Release版本的区别?0XCCCCCCCC是什么
- android_定位的介绍
- The Network Adapter could not establish the connection at oracle.jdbc.driver.T4CConnection.logon
- 【个人】我与机房的初♂夜
- 1081. Rational Sum (20)【模拟】——PAT (Advanced Level) Practise
- 最小生成树kruskal
- mongodb调优那些事(一)-系统设置
- Spinner报错: java.lang.RuntimeException: setOnItemClickListener cannot be used with a spinner.
- java 找出n个元素数组中重复次数最多的数(假设出现次数大于n/2)
- 1082. Read Number in Chinese (25)【字符串处理】——PAT (Advanced Level) Practise
- 1083. List Grades (25)【水题】——PAT (Advanced Level) Practise