First, download and unzip the database driver
: http://www.mysql.com/products/connector/, this article downloads mysql-connector-java-5.0.8.zip. Copy the extracted Mysql-connector-java-5.0.8-bin.jar to the D:\Program Files\weka-3-6\lib (Lib creates a new folder for itself).
Second, set environment variables
Weka_home:d:\program files\weka-3-6
Classpath:%weka_home%\lib\mysql-connector-java-5.0.8-bin.jar
Third, modify the Weka.jar
1. Extract Weka.jar to a directory (package here)
2, in D:\Program files\weka-3-6\package\weka\ Find DatabaseUtils.props.mysql in experiment, change its name to Databaseutils.props, replace the original Databaseutils.props file, and modify the corresponding content in the file as follows:
# JDBC Driver (comma-separated list)
Jdbcdriver=com.mysql.jdbc.driver
# database URL
Jdbcurl=jdbc:mysql://localhost:3306/db_predict (db_predict for database name)
# specific data types, remove comment, change to Weka supported format
string, getString () = 0; Nominal
Boolean, getboolean () = 1; --Nominal
Double, getdouble () = 2; & nbsp --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; & nbsp; --Date
Bigdecimal,getbigdecimal () =11; -->nominal
#mysql-conversion-type conversion, do the following supplement
Tinyint=3
Smallint=4
Short=5
Integer=5
Int=5
Int_unsigned=6
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=8
Date=8
Time=8
Datetime=8
Timestamp=8
3, RePack. The command line enters D:\Program Files\weka-3-6\package, executes the command: Jar CVF weka.jar Java_cup meta-inf Weka, replacing the original Weka.jar.
Four, running Weka
Click explorer>> click Open db>> Click user>> Enter user name, password >> Click Connect
Represents success
Weka Connecting MySQL Database