以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 Java/Eclipse 』  (http://bbs.xml.org.cn/list.asp?boardid=41)
----  请求帮忙解决:jbuilder和mysql 连接错误问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=41&rootid=&id=48491)


--  作者: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
请各位大大指点 可能是什么问题?我已经试了很多次,都不行,郁闷中。请求帮助。

我将在线等,早上睡觉,其余时间在线等待,麻烦高人帮忙解决


--  作者:xqs1239
--  发布时间:6/14/2007 6:16:00 AM

--  
换了个mysql-connector-java-3.1.12版本,现在可以了
--  作者:gogonow
--  发布时间:7/4/2007 1:56:00 PM

--  换个连接器
换个连接器就行了.
--  作者:gogonow
--  发布时间:7/4/2007 1:57:00 PM

--  为什么还用my sql
为什么还用my sql
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms