WEKA连接MySQL的方法

来源:互联网 发布:网络游戏音乐 编辑:程序博客网 时间:2024/05/19 01:29

修改DatabaseUtils.props

进入%WEKA_HOME%/weka/weka/experiment/你会看到:
...
DatabaseUtils.props
DatabaseUtils.props.hsql
DatabaseUtils.props.mssqlserver2005
DatabaseUtils.props.mssqlserver
DatabaseUtils.props.mysql
DatabaseUtils.props.odbc
DatabaseUtils.props.oracle
DatabaseUtils.props.postgresql
...
weka运行时会使用DatabaseUtils.props
其他的如:'DatabaseUtils.props.数据库名称'(这些是weka提供的针对不同数据库提供的模板)

将DatabaseUtils.props.mysql改成DatabaseUtils.props(假设我们需要连接mysql数据库)
打开现在的DatabaseUtils.props

jdbcDriver=org.gjt.mm.mysql.Driver
[修改为-->jdbcDriver=com.mysql.jdbc.Driver]

# string, getString() = 0;    --> nominal
# boolean, getBoolean() = 1;  --> nominal
# double, getDouble() = 2;    --> numeric
# byte, getByte() = 3;        --> numeric
# short, getByte()= 4;        --> numeric
# int, getInteger() = 5;      --> numeric
# long, getLong() = 6;        --> numeric
# gloat, getFloat() = 7;      --> numeric
# date, getDate() = 8;        --> date
# text, getString() = 9;      --> string

修改为

string, getString() = 0;    --> nominal
 boolean, getBoolean() = 1;  --> nominal
 double, getDouble() = 2;    --> numeric
 byte, getByte() = 3;        --> numeric
 short, getByte()= 4;        --> numeric
 int, getInteger() = 5;      --> numeric
 long, getLong() = 6;        --> numeric
 gloat, getFloat() = 7;      --> numeric
 date, getDate() = 8;        --> date
 text, getString() = 9;      --> string
TINYINT=3
SMALLINT=4
#SHORT=4
SHORT=5
INTEGER=5
INT=5
BIGINT=6
LONG=6
REAL=7
NUMERIC=2
DECIMAL=2
FLOAT=2
DOUBLE=2
CHAR=0
TEXT=0
VARCHAR=0
LONGVARCHAR=9
BINARY=0
VARBINARY=0
LONGVARBINARY=9
BIT=1
BLOB=9
DATE=8
TIME=8
DATETIME=8
TIMESTAMP=8

再保存文件就行了

转自http://blog.csdn.net/striker/archive/2009/03/14/3991169.aspx

 

原创粉丝点击