how to connect mysql databases in weka?

2019-05-09 13:28发布

问题:

i want to use my mysql databases in weka in order to analysis data. i download the mysql-connector-java-5.0.8-bin.jar and put that in weka folder in my program Files folder, and add this path to system variable path, but when i open the weka explorer and click the openDB, i don't know what should i write in the url textbox, i don't know completely what should i do? the error that i saw is:

problem connecting to database: no suitable driver found for!

please give me a total guidance, thanks in advance.

回答1:

add mysql-connector-java-5.1.12-bin.jar to CLASSPATH . or put it in weka folder, navigate to weka installation folder and run command :

%java_home%/bin/java -Xmx300M -cp ".;weka.jar;mysql-connector-java-5.1.12-bin.jar;" weka.gui.GUIChooser

then click open DB and

  • fill in the proper user+password
  • put the url: jdbc:mysql://localhost:3306/DATABASENAME

Click Execute. The result window should show the results now.



回答2:

For Weka 3.7.10, the classpath system environment variable is not took into account (at leat under Windows 7). The only working approach for me was to modify the RunWeka.ini file from the Weka installation folder as follows: the cp= setting was modified to:

cp=%CLASSPATH%;d:/Programs/jdbc/mysql-connector-java-5.1.26/mysql-connector-java-5.1.26-bin.jar

whereas only the %CLASSPATH%; setting was originally provided. Does not make much sense, but in worked.



回答3:

find some introduction to WEKA and the environment variable: http://weka.wikispaces.com/CLASSPATH



回答4:

Copy mysql-connector-java-X.X.XX-bin.jar to /usr/share/java/ unizip /usr/share/java/weka.jar

edit: /usr/share/java/weka/experiment/DatabaseUtils.props

add: jdbcDriver=com.mysql.jdbc.Driver jdbcURL=jdbc:mysql://localhost:3306/test (with your server)

add shell export CLASSPATH=/usr/share/java/mysql-connector-java-X.X.XX-bin.jar: export CP=/usr/share/java/mysql-connector-java-X.X.XX-bin.jar::/usr/share/java/:/usr/shared/java/weka.jar

execute weka:

java -cp $CP -Xmx500m weka.gui.explorer.Explorer

Ready



标签: mysql jdbc weka