Weka訪問MySQL資料庫

來源:互聯網
上載者:User

在Weka中使用Experimenter想串連Mysql資料庫時, 預設連結為:

jdbc:idb=experiments.prp

將其改為:

jdbc:mysql://222.35.250.58:3306/labin_ultimate_original

(Mysql主機與資料庫名需要根據實際情況設定)

仍然會出現錯誤:

exception: java.sql.SQLException: No suitable driver found for jdbc:mysql ...

這是因為Weka沒有找到JDBC的驅動程式。

即使從http://dev.mysql.com/downloads/connector/j/

下載了JDBC驅動,安裝上(設定CLASSPATH到指定bin.jar檔案),發覺仍然不行。

查看源檔案DatabaseUtils.prop原始碼,其中的配置如下

# The comma-separated list of jdbc drivers to use

#jdbcDriver=RmiJdbc.RJDriver,jdbc.idbDriver

#jdbcDriver=jdbc.idbDriver

jdbcDriver=RmiJdbc.RJDriver,jdbc.idbDriver,org.gjt.mm.mysql.Driver,com.mckoi.JDBCDriver,org.hsqldb.jdbcDriver

#jdbcDriver=org.gjt.mm.mysql.Driver

# The url to the experiment database

#jdbcURL=jdbc:rmi://expserver/jdbc:idb=experiments.prp

jdbcURL=jdbc:idb=experiments.prp

#jdbcURL=jdbc:mysql://mysqlserver/username

這下就可以知道原因了:原來Weka只設定了org.gjt.mm.mysql.Driver作為JDBC的驅動,www.bkjia.com沒有設定com.mysql.jdbc.Driver!

下載個org.git.mm.mysql.Driver的驅動安裝上就可以了。

或者,講experiment目錄下的jdbcDriver配置改為:

jdbcDriver=RmiJdbc.RJDriver,jdbc.idbDriver,org.gjt.mm.mysql.Driver,com.mckoi.JDBCDriver,org.hsqldb.jdbcDriver,com.mysql.jdbc.Driver

(增加com.mysql.jdbc.Driver驅動)

其實使用Weka的預設設定,使用起來會有許多不方便的地方,最好是將其配置全部修改為與自己相合的配置後再打包運行。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.