标题:谁知道这到底是怎么回事,java连接oracle数据库,在eclipse下已经引入class ...
只看楼主
飞黄腾达
Rank: 2
等 级:论坛游民
帖 子:46
专家分:27
注 册:2013-3-14
结帖率:29.41%
已结贴  问题点数:20 回复次数:3 
谁知道这到底是怎么回事,java连接oracle数据库,在eclipse下已经引入classes12.jar包了,还是不行,真么郁闷
package student;
import java.lang.*;
import java.sql.*;
public class JDBCoracle{
   
        
        public static final String driverClassName = "oracle.jdbc.driver.OracleDriver";
        public static final String url = "jdbc:oracle:thin:@localhost:1521:orcl";
        public static final String password = "472312";
        public static final String user= "sys as sysdba";
        public static void main(String[] args) throws Exception{
             Connection conn = null;
             Class.forName(driverClassName);
             conn = DriverManager.getConnection(url, user, password);
            System.out.println(conn);
            conn.close();
            
         
        }
    }
错误异常:
Exception in thread "main" java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:345)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:428)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:515)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:345)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at student.JDBCoracle.main(JDBCoracle.java:14)

搜索更多相关主题的帖子: localhost password package oracle public 
2013-10-26 19:27
hhwz
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:87
帖 子:687
专家分:4502
注 册:2011-5-22
得分:10 
加一个main方法
这是入口方法
2013-10-26 23:47
经哥
Rank: 3Rank: 3
来 自:代码空间
等 级:论坛游侠
威 望:1
帖 子:289
专家分:124
注 册:2012-9-8
得分:10 
回复 2楼 hhwz
求关于main入口的博客文章链接

我只是个演员,还是业余的!!
2013-10-28 23:29
hhwz
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:87
帖 子:687
专家分:4502
注 册:2011-5-22
得分:0 
回复 3楼 经哥
百度 GOOGLE一下就找到了
2013-10-29 09:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-422565-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.192565 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved