遇到这个问题了 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包就不行。