Java中相关的代码:
Class.forName( "oracle.jdbc.driver.OracleDriver " ) ;
conn = DriverManager.getConnection( "jdbc:oracle:thin:@LvQiang:1521:Oracle ", "SYSTEM " , "zrc775fp ")
抛出的异常:
java.sql.SQLException:Io 异常: The Network Adapter could not establish the connection-oracle
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:274)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:319)
at oracle.jdbc.driver.PhysicalConnection. <init> (PhysicalConnection.java:344)
at oracle.jdbc.driver.T4CConnection. <init> (T4CConnection.java:148)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
我能肯定主机名、端口号、数据库名称都是正确的,可是为什么我这个还是连不上呢?我用的是路由器,在路由器里面我设置了路由器的IP地址为:192.168.1.2,可是我把LvQiang换上这个IP地址运行以后也是不成!!我不知道是什么原因了,我安装的Oracle数据库是9i版本的,装在了电脑的G:\Oracle9i这个目录下,请高手给我指点指点吧,我要急疯了!!!!!!!!
------解决方法--------------------------------------------------------
用
( "jdbc:oracle:thin:@127.0.0.1:1521:Oracle ", "SYSTEM " , "zrc775fp ")
试试
还有看看SID有没有写错,