【发布时间】:2016-06-11 12:39:54
【问题描述】:
我使用 MAVEN 使用 Weka 3.7.13 开发版构建了一个简单的 weka 应用程序。我已经初始化了 pom.xml 函数以从存储库中获取 weka 库。
我想使用 weka 运行一个简单的聚类算法,并将其连接到 MySQL 数据库。根据文档,weka 需要有一个 DatabaseUtil.props 文件,其中包含它的 jdbc 驱动程序。我已经设置好了。
这是我的项目结构:
我可以使用下面的代码检索 DatabaseUtils.props。但不知何故,weka 本身无法识别我已经在里面配置的 jdbc:Url and driver 名称。
DatabaseUtil.props文件:
# JDBC driver (comma-separated list)
jdbcDriver=com.mysql.jdbc.Driver
# database URL
jdbcURL=jdbc:mysql://127.0.0.1:3306/datamining
我触发 Weka 模块的 Java 代码:
public void dm(){
int cluster = 4;
InstanceQuery clusterQuery = null;
try{
//file reader of database utilities properties
ClassLoader classLoader = getClass().getClassLoader();
File fileProps = new File(classLoader.getResource("DatabaseUtils.props").getFile());
//setup the data preparation functionality then connect to database
clusterQuery = new InstanceQuery();
clusterQuery.setUsername("test");
clusterQuery.setPassword("test");
clusterQuery.setQuery("SELECT * FROM TEMP_KMEANS");
clusterQuery.setCustomPropsFile(fileProps);
但是执行函数时返回错误:java.sql.SQLException: No suitable driver found for jdbc:idb=experiments.prp
看来DatabaseUtils.props文件无法覆盖默认驱动值jdbc:idb=experiments.prp
任何想法为什么这是抛出?
非常感谢任何反馈和回答。
【问题讨论】: