简体   繁体   中英

WEKA - JDBC Connection Exception

I'm facing JDBC connection problem while trying to connect MySQL DB using WEKA.

Here's my DatabaseUtils.properties file:

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

And I added jdbc-mysql jar into the path:

/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]

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".

You can override them with DatabaseUtils.properties file. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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