双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

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

Frisk Frisk 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是我的代码!


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包就不行。
...全文
评论 2
收藏 已收藏
分享
返回顶部
Frisk
Java EE 67,535 成员 225,843 内容