Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate » Oracle  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 java+oracle(No suitable driver)
cooper131





发贴: 7
积分: 0
于 2006-11-15 20:57 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

import java.sql.*;

public class testDB{
public static void main(String[] args){
String serverName="127.0.0.1";
try{
Class c=oracle.jdbc.driver.OracleDriver.class;
String url="jdbc:oracle: @"+serverName+":1521: XE";
Connection conn=DriverManager.getConnection(url,"12345","12345");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from user_db");
while(rs.next()){
System.out.print("id:"+rs.getString(1));
System.out.println("name:"+rs.getString(2));
}
rs.close();
stmt.close();
conn.close();
}catch(SQLException sqle){
System.out.println("database is error.~~~~~~~~~~~~!!!!");
sqle.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}

}
}

=======================================
在DOS在运行:
database is error.~~~~~~~~~~~~!!!!
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at testDB.main(testDB.java:9)
=======================================
当我用eclipse运行时,通过了,读到数据了。
注:在DOS下我用的是与eclipse一样的ojdbc14.jar文件。
我还试过Classes12.jar,也不行。
让我最想不通的是同一段代码一个通过,另一个不行!!!
我认为是运行环境有所不同,但就是找不到有什么不同。
高手指点一下,谢谢


why edited on 2006-11-16 07:43

事事无常
作者 Re:java+oracle(No suitable driver) [Re:cooper131]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-11-16 07:45 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
String url=jdbc:oracle:thin:@"+serverName+":1521:XE";

why edited on 2006-11-16 07:50

作者 Re:java+oracle(No suitable driver) [Re:cooper131]
cooper131





发贴: 7
积分: 0
于 2006-11-16 11:10 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
先谢谢你,能抽时间回答这个问题

呵呵,那个空格是我后加的,不加出个小鬼脸,还有那个thin,我也加过不行。

我用这个(带thin的)url在eclipse运行通过了,在DOS下不行,不知为什么?



事事无常
作者 Re:java+oracle(No suitable driver) [Re:cooper131]
cooper131





发贴: 7
积分: 0
于 2006-11-21 20:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
已解决,我jdk用1.5,后来我改用1.4.2后好用了


事事无常
作者 Re:java+oracle(No suitable driver) [Re:cooper131]
九佰



版主


发贴: 983
积分: 126
于 2006-11-24 16:57 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
cooper131 wrote:
先谢谢你,能抽时间回答这个问题

呵呵,那个空格是我后加的,不加出个小鬼脸,还有那个thin,我也加过不行。

我用这个(带thin的)url在eclipse运行通过了,在DOS下不行,不知为什么?


在发贴的确定按纽上有一选项: 禁止在这个帖子中使用笑脸标记
把它选上就不会出现笑脸了.




http://www.teamlet.org

海纳百川,有容乃大
壁立千仞,无欲则刚
智者不惑,勇者无惧
止戈为武,仁者无敌
作者 Re:java+oracle(No suitable driver) [Re:cooper131]
yuandian1984





发贴: 3
积分: 0
于 2008-03-06 09:04 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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