遇到这个问题了 The driver: com.mysql.jdbc.Driver could not be loaded.

Frisk 2005-06-17 09:50:42
这是我的代码!


String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=gb2312";
String user = "root";
String pwd = "welcome";

Database db = new Database();
db.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor(url, user, pwd, false,driver));

QueryDataSet qds = new QueryDataSet();
String sql = "SELECT * FROM mytest";
qds.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(db, sql, null, true, Load.ALL));
qds.open();
while (qds.next() == true){
System.out.print("id :"+qds.getInt(1));
System.out.print("name :"+qds.getString(2));
System.out.print("id :"+qds.getString(3));
}

qds.close();
db.closeConnection();


但运行结果却是
See com.borland.dx.dataset.DataSetException error code: BASE+83
com.borland.dx.dataset.DataSetException: The driver: com.mysql.jdbc.Driver could not be loaded. This could be a problem with the driver itself, or that the driver is not found on the classpath.
at com.borland.dx.dataset.DataSetException.a(Unknown Source)
at com.borland.dx.dataset.DataSetException.driverNotLoadedAtRuntime(Unknown Source)
at com.borland.dx.sql.dataset.Database.addDriver(Unknown Source)
at com.borland.dx.sql.dataset.Database.addDrivers(Unknown Source)
at com.borland.dx.sql.dataset.Database.openConnection(Unknown Source)
at com.borland.dx.sql.dataset.Database.createPreparedStatement(Unknown Source)
at com.borland.dx.sql.dataset.o.a(Unknown Source)
at com.borland.dx.sql.dataset.o.d(Unknown Source)
at com.borland.dx.sql.dataset.o.f(Unknown Source)
at com.borland.dx.sql.dataset.QueryProvider.e(Unknown Source)
at com.borland.dx.sql.dataset.JdbcProvider.provideData(Unknown Source)
at com.borland.dx.dataset.StorageDataSet.a(Unknown Source)
at com.borland.dx.dataset.DataSet.a(Unknown Source)
at com.borland.dx.dataset.DataSet.open(Unknown Source)
at mysql.DbManager.main(DbManager.java:44)
Exception in thread "main"


我用的是eclipse 同样的开发环境,同样的工程,用jdbc标准的方式就没问题。但用borland包就不行。
...全文
467 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jihanzhong 2005-06-17
  • 打赏
  • 举报
回复
This could be a problem with the driver itself, //可能是驱动本身问题
that the driver is not found on the classpath.//或者是你的classpath不对

不过确认classpath没错,考虑更新driver版本
rower203 2005-06-17
  • 打赏
  • 举报
回复
borland包的问题,不要用它。

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧