<span style="font-size:14px;">export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_25 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:/home/chicho/tools/weka-3-7-12/lib/mysql-connector-java-5.1.27-bin.jar export PATH=${JAVA_HOME}/bin:$PATH export PATH=$PATH:/home/chicho/tools/weka-3-7-12/weka.jar</span>
3.由于weka是基于java开发的,在Linux(Ubuntu平台)Java通过JDBC连接MySQL数据库,我们还要进行以后的操作,步骤如下:
下载 jdbc: mysql-connector-java-5.1.18.tar.gz
解压 jdbc: tar -zxvf mysql-connector-java-5.1.18.tar.gz
配置 jdbc:cp mysql-connector-java-5.1.18-bin.jar /usr/local/jdk1.8.0_25/jre/lib/ext/
这一步很关键不要忘记,否则会出错。
用归档器打开weka.jar\experiment里找到DatabaseUtils.props
# General information on database access can be found here:
# http://weka.wikispaces.com/Databases
#
# Version: $Revision: 11144 $
# The comma-separated list of jdbc drivers to use
#jdbcDriver=RmiJdbc.RJDriver,jdbc.idbDriver
#jdbcDriver=jdbc.idbDriver
#jdbcDriver=RmiJdbc.RJDriver,jdbc.idbDriver,org.gjt.mm.mysql.Driver,com.mckoi.JDBCDriver,org.hsqldb.jdbcDriver
#jdbcDriver=org.gjt.mm.mysql.Driver
jdbcDriver=com.mysql.jdbc.Driver
# The url to the experiment database
#jdbcURL=jdbc:rmi://expserver/jdbc:idb=experiments.prp
#jdbcURL=jdbc:idb=experiments.prp
#jdbcURL=jdbc:mysql://mysqlserver/username
jdbcURL=jdbc:mysql://localhost:3306/database_name
# the method that is used to retrieve values from the db
# (java datatype + RecordSet.<method>)
# 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
# float, getFloat() = 7; --> numeric
# date, getDate() = 8; --> date
# text, getString() = 9; --> string
# time, getTime() = 10; --> date
# the original conversion: <column type>=<conversion>
#char=0
#varchar=0
#longvarchar=0
#binary=0
#varbinary=0
#longvarbinary=0
#bit=1
#numeric=2
#decimal=2
#tinyint=3
#smallint=4
#integer=5
#bigint=6
#real=7
#float=2
#double=2
#date=8
#time=10
#timestamp=8
#mysql-conversion
CHAR=0
TEXT=0
VARCHAR=0
LONGVARCHAR=9
BINARY=0
VARBINARY=0
LONGVARBINARY=9
BIT=1
NUMERIC=2
DECIMAL=2
FLOAT=2
DOUBLE=2
TINYINT=3
SMALLINT=4
#SHORT=4
SHORT=5
INTEGER=5
BIGINT=6
LONG=6
REAL=7
DATE=8
TIME=10
TIMESTAMP=8
#mappings for table creation
CREATE_STRING=TEXT
CREATE_INT=INT
CREATE_DOUBLE=DOUBLE
CREATE_DATE=DATETIME
DateFormat=yyyy-MM-dd HH:mm:ss
#database flags
checkUpperCaseNames=false
checkLowerCaseNames=false
checkForTable=true
setAutoCommit=true
createIndex=false
# All the reserved keywords for this database
Keywords=\
AND,\
ASC,\
BY,\
DESC,\
FROM,\
GROUP,\
INSERT,\
ORDER,\
SELECT,\
UPDATE,\
WHERE
# The character to append to attribute names to avoid exceptions due to
# clashes between keywords and attribute names
KeywordsMaskChar=_
#flags for loading and saving instances using DatabaseLoader/Saver
nominalToStringLimit=50
idColumn=auto_generated_id
添加红色的部分.
jdbcURL=jdbc:mysql://localhost:3306/database_name 《==这个部位根据你的需求自己改变。
保存,更新即可。