-- 作者:xqs1239
-- 发布时间:6/14/2007 3:31:00 AM
-- 请求帮忙解决:jbuilder和mysql 连接错误问题
在此请教一下,我用jbuilder和mysql已经配置好,用database pilot 可以看到数据库中的信息,然后在程序中连接 代码如下: Connection conn=null; Statement stmt=null; ResultSet rs=null; String DB_URL = "jdbc:mysql://localhost:3306/owl_db"; // URL of database String DB_USER = "owluser"; // database user id String DB_PASSWD = "owluserpwd"; // database password try{ Class.forName ("com.mysql.jdbc.Driver"); // Load the Driver conn=DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWD); stmt=conn.createStatement(); String sql ="INSERT INTO owl_subclass(subclass,superclass) VALUES ('branch','plant')"; stmt.executeUpdate(sql); rs=stmt.executeQuery("select * from owl_subclass"); while(rs.next()) { System.out.println(rs.getString(1)); System.out.println(rs.getString(2)); System.out.println(rs.getString(3)); } rs.close(); stmt.close(); conn.close(); }catch(Exception e){ System.out.println("the database is error!"); } finally{ if (rs != null) { try { rs.close(); } catch (Exception ignore) { } } if (stmt != null) { try { stmt.close(); } catch (Exception ignore) { } } if (conn != null) { try { conn.close(); } catch (Exception ignore) { } } } 可是总是输出the database is error! 信息并没有被插入表中,请问这可能是什么问题,另外需要在数据源(odbc)中设置吗?可是里面没有mysql的选项。 另外我在设置dataexpress组件中的database中的connection时test connection也始终失败 显示信息是 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. 另外我是jbuilder2006 +mysql 4.0.26+mysql-connector-java-3.1.14 请各位大大指点 可能是什么问题?我已经试了很多次,都不行,郁闷中。请求帮助。 我将在线等,早上睡觉,其余时间在线等待,麻烦高人帮忙解决
|