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

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 java与数据库的问题
haoyue





发贴: 24
积分: 0
于 2004-08-04 15:12 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
我在运行一个连接到Access数据庫的java程序时,出了如下错误,能帮我想想办法吗?
错误是:
    Can not load jdbc--odbc Bridge Driver
ClassNotFoundException:sun/jdbc/odbc,jdbcOdbcDriver
SQLException:
Message:No suitable driver
程序是:
    import java.net.URL;
import java.sql.*;

class StudentAccess
{
public static void main(String args[])
{
String url="jdbc:odbc:Student";
//Student是已经建立的ODBC数据源名称
try
{
try
{
//加载JDBC-ODBC Bridge驱动程序
Class.forName("sun.jdbc.odbc,jdbcOdbcDriver");
//sun.jdbc.odbc.jdbcOdbcDriver是jdbc--Odbc桥在JDK中的类名,
//要注意的是,在不同的开发环境中,是驱动程序的类可能包含在不同的包里
}
catch(java.lang.ClassNotFoundException e)
{
System.out.println("Can not load jdbc--odbc Bridge Driver");
System.err.print("ClassNotFoundException:");
System.err.println(e.getMessage());
}
Connection con=DriverManager.getConnection(url);
//使用指定的url连接数据库
DatabaseMetaData dmd=con.getMetaData();
System.out.println("连接的数据库:"+dmd.getURL());
System.out.println("驱动程序:"+dmd.getDriverName());
}
catch(SQLException ex)
{
System.out.println("SQLException:");
while(ex!=null)
{
System.out.println("Message:"+ex.getMessage());//打印出错信息
ex=ex.getNextException();
}
}
}
}
另外,请问我能到哪下载到一些常用的数据库的驱动程序呢?(如:Access、SQL sever 2000等的)
望大家多指教。




话题树型展开
人气 标题 作者 字数 发贴时间
4684 java与数据库的问题 haoyue 1633 2004-08-04 15:12
4288 Re:java与数据库的问题 joelwx 57 2004-08-04 15:49
4001 Re:java与数据库的问题 tangming 58 2004-08-04 16:06
3946 Re:java与数据库的问题 haoyue 149 2004-08-05 08:52
4120 Re:java与数据库的问题 href 260 2004-08-11 16:38
3789 Re:java与数据库的问题 helloworld 805 2004-08-05 09:07
4003 Re:java与数据库的问题 haoyue 13 2004-08-05 15:55

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