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

您没有登录

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

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





发贴: 5
积分: 0
于 2006-05-15 09:39 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
我用JBuilder做了个单机版的小程序,用的Access数据库,其中用来定义数据库的类如下:

public class dbBean {
String driver="sun.jdbc.odbc.JdbcOdbcDriver"; //加载驱动
String connstr="jdbc:odbc:book"; //定义连接数据库名
Connection conn=null; //定义一个连接
ResultSet rs=null; //存放返回结果集
public dbBean() {
try{
Class.forName(driver); //获得JDBC-ODBC桥驱动程序
}
catch(java.lang.ClassNotFoundException e){ //异常的处理
System.err.println("DBBean():"+e.getMessage());
}
}
public ResultSet executeQuery(String sql){ //定义查询的方法
rs=null;
try{ //获得驱动的连接
conn=DriverManager.getConnection(connstr);
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql); //执行查询
}
catch(SQLException e){
System.err.println("executeQuery:"+e.getMessage());
}
return rs; //返回结果集
}
}

可是运行的时候出现:
No suitable driver

我找了一些资料,没有发现哪里有提到过连接Access数据库要用什么驱动来实现的,请大家帮帮忙吧!!!!!!



作者 Access数据库的连接(参数不足,期待是 1) [Re:abu121]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-05-15 19:09 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
abu121 posted:

不好意思,又是我,同样一些代码:

public class dbBean {
String driver="sun.jdbc.odbc.JdbcOdbcDriver"; //加载驱动
String connstr="jdbc:odbc:book"; //定义连接数据库名
Connection conn=null; //定义一个连接
ResultSet rs=null; //存放返回结果集
public dbBean() {
try{
Class.forName(driver); //获得JDBC-ODBC桥驱动程序
}
catch(java.lang.ClassNotFoundException e){ //异常的处理
System.err.println("DBBean():"+e.getMessage());
}
}
public ResultSet executeQuery(String sql){ //定义查询的方法
rs=null;
try{ //获得驱动的连接
conn=DriverManager.getConnection(connstr);
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql); //执行查询
}
catch(SQLException e){
System.err.println("executeQuery:"+e.getMessage());
}
return rs; //返回结果集
}
}

现在的错误是:
[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。

这个又是怎么回事呀?????



What is your query (sql)? -- why


why edited on 2006-06-04 20:22

作者 Re:Access数据库的连接 [Re:abu121]
gip





发贴: 21
积分: 0
于 2006-06-04 18:35 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
检查下odbc又没有配对



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