Topic: 连接数据库失败!我觉得是个基础问题

  Print this page

1.连接数据库失败!我觉得是个基础问题 Copy to clipboard
Posted by: RingofAngel
Posted on: 2005-09-13 08:16


public void connectDB(){
try {

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection(
"jdbc:oracle:thin:@172.17.10.4:1521:prod9i", "doc", "doc");
stmt = con.createStatement();
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog( this,"连接数据库失败" );
System.exit(0);
}
}


提示异常信息:
java.lang.NoClassDefFoundError: oracle/jdbc/drive
at login.login.connectDB(login.java:167)
at login.login.jbInit(login.java:94)
at login.login.init(login.java:53)
at sun.applet.AppletPanel.run(AppletPanel
at java.lang.Thread.run(Thread.java:534)

其中第167行
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

请问我该如何解决,我用的是jbuilder,在IDE下可以成功运行,但是用命令行
运行就是这样的异常,请问是不是要在环境变量里边添加什么,我该如何做??

2.Re:连接数据库失败!(NoClassDefFoundError) [Re: RingofAngel] Copy to clipboard
Posted by: why
Posted on: 2005-09-13 08:29

include Oracle's JDBC jar in the classpath

3.Re:连接数据库失败!(NoClassDefFoundError) [Re: why] Copy to clipboard
Posted by: RingofAngel
Posted on: 2005-09-13 10:07

找到了oracle官网,去下oracle9i的jdbc
可是不管I Accept之后,总是sorry的页面,我问了不少人,也都不行
用google搜索,千篇一律的转的同一个下载地址,真不知道这帮人干什么这么愿意做混淆视听的事。

哪位帮个忙,给出另一个下载地址,或者直接发到我的邮箱好吗??

wangjq@hayaozong.com

4.Re:连接数据库失败!我觉得是个基础问题 [Re: RingofAngel] Copy to clipboard
Posted by: why
Posted on: 2005-09-13 11:13

If you have Oracle installed, you could find the jar file (ojdbc14.jar?) somewhere in a subfolder.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923