0
protected void setup() {
     System.out.println("Hello Buyer Agent "+getAID().getName()+" is now ready....");
     String url = "jdbc:mysql://localhost/";
     String dbName = "testdb";
     String driver = "com.mysql.jdbc.Driver";
     String userName = "root";
     String password = "pass";

      try {
           Class.forName(driver).newInstance();
           Connection conn = DriverManager.getConnection(url+dbName,userName,password);
           Statement st = conn.createStatement();
           ResultSet res = st.executeQuery("SELECT * FROM  requested_electric_prods ORDER BY created DESC LIMIT 1");
           while (res.next()) {
                elec_pro_name = res.getString("search_string");
                elec_pro_requested_min_price  = res.getInt("price_min");
                elec_pro_requested_max_price = res.getInt("price_max");
                System.out.println("Customer requested, product: "+ elec_pro_name + " min price: "+ elec_pro_requested_min_price + " max price: " + elec_pro_requested_max_price);
           }

           conn.close();
       } catch (Exception e) {
           e.printStackTrace();
       }

这是我的设置方法。这真的很简单。但是当它尝试连接到数据库时,它仍然会给出 classNotFoundException。

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

我有 JDBC 驱动程序并已将其添加到构建路径。我正在使用 Ecipe 和 EJADE 插件。有谁知道为什么会这样?在启动代理之前是否需要进行更多配置?

4

1 回答 1

0

主要问题是 EJADE 插件和 Eclipse 最新版本:Juno 之间的某种不兼容。我改为 Eclipse Indigo,一切正常!

于 2013-06-18T16:37:25.920 回答