<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 《==這個部位根據你的需求自己改變。
保存,更新即可。