How to connect to a database in Weka

Source: Internet
Author: User

Related preparation:

Weka, MySQL is installed

MYSQL Driver for JDBC

1, enter the Weka installation directory

1) Create new folder Lib and folder Weka, and then copy the Mysql-connector-java-5.1.24-bin.jar to the Lib folder

2) "My Computer" property, set environment variables

The installation directory for the new variable Weka_home=weka, such as (D:\Prgrams\weka-3.6)

Add ";%weka_home%\lib\mysql-connector-java-5.1.24-bin.jar" to the CLASSPATH variable

3) Unzip the Weka.jar into the Weka folder (new), then go to Weka\experiment, find Databaseutils.props (default), and make the following changes:

# JDBC Driver (comma-separated list)
#jdbcDriver =org.gjt.mm.mysql.driver
Modified to: Jdbcdriver=com.mysql.jdbc.driver
# database URL, remains the same
Jdbcurl=jdbc:mysql://server_name:3306/database_name

# Specific data types, the specific type of the changes are as follows, mainly to remove the comments
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
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

Other temporarily without modification, save

4) Copy the Databaseutils.props file that you just modified to the installation directory of Weka, and then delete the Weka folder created above (without replacing the original Weka.jar, replacing the weka instead of opening it)

5) Open the Runweka.ini file to the tail of the file

# the Classpath placeholder. ADD any environment variables or jars to it
# Need for your Weka environment.
# Example with an enviroment variable (e.g., third_party_libs):
# cp=%classpath%;%third_party_libs%
# Example with a extra jar (located at D:\libraries\libsvm.jar):
# cp=%classpath%;D: \\\\libraries\\\\libsvm.jar
# Or in order to avoid quadrupled backslashes, you can also use slashes "/":
# cp=%classpath%;D:/libraries/libsvm.jar
Modified to (Add driver file path): cp=%classpath%;D:/programs/weka-3.6/lib/mysql-connector-java-5.1.24-bin.jar
#cp =%classpath%

Save

2. Run Weka, enter Explorer-->open DB

In the URL box, type: Jdbc:mysql://localhost:3306/mysql (localhost is the server name, and the last MySQL is the name of the database to be accessed, modify it yourself to ensure that the database to be accessed exists)

Click User: After entering your username and password, click Connect,

If the connecting To:jdbc:mysql://localhost:3306/mysql = True is displayed in the info box below, the connection succeeds, otherwise it fails.

I tried it here and it was a success.

You can enter the SQL statement in the query box and click Excute to execute.

Other database connections are not yet tried, to be continued.

Transferred from: http://blog.sina.com.cn/s/blog_60fde0c701010hta.html

How to connect to a database in Weka (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.