简体   繁体   English

WEKA-JDBC连接异常

[英]WEKA - JDBC Connection Exception

I'm facing JDBC connection problem while trying to connect MySQL DB using WEKA. 尝试使用WEKA连接MySQL数据库时,我遇到JDBC连接问题。

Here's my DatabaseUtils.properties file: 这是我的DatabaseUtils.properties文件:

jdbcDriver=com.mysql.jdbc.Driver
jdbcURL=jdbc:mysql://localhost:3306/mydb

And I added jdbc-mysql jar into the path: 我在路径中添加了jdbc-mysql jar:

/opt/SenchaSDKTools-2.0.0-beta3:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/talha/apache-maven-3.0.4/bin:/home/talha/mysql-connector-java-5.1.20.jar:/opt/SenchaSDKTools-2.0.0-beta3:/home/talha/apache-maven-3.0.4/bin:/usr/lib/jvm/jdk1.7.0_05/bin:/home/talha/apache-maven-3.0.4/bin

Java Class [A simple test class] Java类[一个简单的测试类]

public class Test {

    public static void main(String[] args) throws Exception {

        InstanceQuery query = new InstanceQuery();
        query.setUsername("username");
        query.setPassword("password");
        String sql = "select * from user";
        query.setQuery(sql);
        // if your data is sparse, then you can say so too
        // query.setSparseData(true);
        Instances data = query.retrieveInstances();

    }

}

Full stacktrace: 完整的堆栈跟踪:

Trying to add database driver (JDBC): RmiJdbc.RJDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): jdbc.idbDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): com.mckoi.JDBCDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): org.hsqldb.jdbcDriver - Error, not in CLASSPATH?
Disconnected from the target VM, address: '127.0.0.1:33305', transport: 'socket'
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:idb=experiments.prp
    at java.sql.DriverManager.getConnection(DriverManager.java:604)
    at java.sql.DriverManager.getConnection(DriverManager.java:221)
    at weka.experiment.DatabaseUtils.connectToDatabase(DatabaseUtils.java:521)
    at weka.experiment.InstanceQuery.retrieveInstances(InstanceQuery.java:286)
    at weka.experiment.InstanceQuery.retrieveInstances(InstanceQuery.java:271)
    at com.tk.miner.Test.main(Test.java:22)

According to JavaDocs InstanceQuery defaults to "jdbc.idbDriver" and "jdbc:idb=experiments.prp". 根据JavaDocs, InstanceQuery默认为“ jdbc.idbDriver”和“ jdbc:idb = experiments.prp”。

You can override them with DatabaseUtils.properties file. 您可以使用DatabaseUtils.properties文件覆盖它们。 Try putting DatabaseUtils.props in user.home (/home/talha/ ?) or the current directory (in Eclipse current directory is project folder that contains src folder - no idea where it is on IntelliJ Idea). 尝试将DatabaseUtils.props放在user.home (/ home / talha /?)或当前目录中 (在Eclipse中,当前目录是包含src文件夹的项目文件夹-不知道它在IntelliJ Idea上的位置)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM