Weka(0)--weka接続データベースjava実装コード
// java weka . weka.jar weka/experiment/DatabaseUtils.props
package com.weka.comm;
import weka.core.Instances;
import weka.experiment.InstanceQuery;
/**
* weka
*
* @author Administrator
*
*/
public class DbUtils {
/**
*
*
* @param url
* @param user
* @param pwd
* @return
*/
public InstanceQuery getQuery(String url, String user, String pwd) {
InstanceQuery query = null;
try {
query = new InstanceQuery();
query.setDatabaseURL(url);
query.setUsername(user);
query.setPassword(pwd);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return query;
}
/**
* sql
*
* @param query
* @param sql
* @return
*/
public Instances getData(InstanceQuery query, String sql) {
Instances data = null;
query.setQuery(sql);
try {
//
data = query.retrieveInstances();
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
}