0
votes

I have successfully installed Weka and need it to connect to our MS SQL Server. But when I start Weka I get the below error:

# java -Xmx1000M -jar weka.jar
---Registering Weka Editors---
Trying to add database driver (JDBC): jdbc.idbDriver - Error, not in CLASSPATH?

Where I can get a the .jar or lib files where I have only the below listed .jar files:

# find . -name "*.jar"
./weka.jar
./weka-src.jar
./remoteExperimentServer.jar
[weka-3-6-12]#

What else I need to install to run Weka successfully.

As per the comment below this is the content of my "weka/experiment/DatabaseUtils.props" file:

# grep -i idbDriver weka/experiment/DatabaseUtils.props

#jdbcDriver=RmiJdbc.RJDriver,jdbc.idbDriver
#jdbcDriver=jdbc.idbDriver
#jdbcDriver=RmiJdbc.RJDriver,jdbc.idbDriver,org.gjt.mm.mysql.Driver,com.mckoi.JDBCDriver,org.hsqldb.jdbcDriver

Since every line starts with '#' that has jdbc.idbDriver I believe that these lines are comment. Am I correct in my understanding - also I believe that this warning / error which can be ignored.

But please let me know what changes I need to make to connect Weka to MS SQL Databases?

2
@SemihEker Thanks I have updated my question accordinglyProgrammer

2 Answers

0
votes

To enable connectivity to MSSQL via weka, do this: (do this if you are on windows)

  1. create a start script
  2. create a DatabaseUtils.props file

Here is my startscript. Note how the $CP variable is set. This contains the full path to the jtds.jar file which contains the jdbc driver for MSSQL.

#!/bin/bash
WEKA_HOME=/opt/smallapps/weka-stable/weka
export WEKA_JAR=$WEKA_HOME/weka.jar
export PATH=$WEKA_HOME:$PATH
CP="/usr/share/java/:/opt/dbvis9/jdbc/jtds/jtds.jar:/opt/database/sqlite/sqlite-jdbc.jar:$WEKA_JAR"
echo "used CLASSPATH: $CP"
DIR=/opt/smallapps/weka-stable/data/
echo "changing to '$DIR'"
cd "$DIR"
export WEKA_HOME=$DIR
# start Weka's small GUIChooser window
java -cp $CP -Xmx500m weka.gui.GUIChooser &

This is the beginning my DatabaseUtils.props file, comments removed, stored at its default location. My full path: /opt/smallapps/weka/wekafiles/DatabaseUtils-mssql.props, linked to /opt/smallapps/weka/wekafiles/DatabaseUtils.props

jdbcDriver=org.sqlite.JDBC,net.sourceforge.jtds.jdbc.Driver

jdbcURL=jdbc:jtds:sqlserver://dbhost.mycompany.com:1433;DatabaseName=master

varchar=0
float=2
numeric=2
tinyint=3
int=5
bigint=6
nvarchar=9
nchar=9
char=9
decimal=2
bit=1
smallint=5
date=8

Here I have addded a screenshot with the buttons to click.

Note that there are no "Connection successful" messages. There will appear only yellow-triangle messages in the console window. (Red X - Icons if connection unsuccessful)

enter image description here

Connection URLs documentation by Microsoft here

0
votes

You can try the steps below. It works for me too but for MySQL. It may be similar within MSSQL. I tried to edit for MSSQL.

1- Download the required Connector from this link.

2- According to your Java version "mssql-jdbc-9.2.1.jre8.jar, mssql-jdbc-9.2.1.jre11.jar, mssql-jdbc-9.2.1.jre15.jar" (These are "sqljdbc_9_2 \ enu" folder they are included) copy the files to the "Weka" folder. You can copy all of them.

3- Then you must enter CLASSPATH value in "Environment Variables" in capital letters. If you are using Windows 7 you will see CLASSPATH already. However, if you are using Windows 10, you may need to add manually. It was like this on my computer: Classpath on Windows 7

4- Copy the DatabaseUtils.probs file to the Weka folder. This file allows you to match the data types in the database with Weka's own data types. If some data types do not match, you must set them in this file.

5- Then you have to open Weka from the start menu. It doesn't work when you turn it on from the console. You don't need a console anyway. You can set the amount of RAM memory in "RunWeka.ini" in the Weka folder.

6- Click Open DB. Enter information on the screen as follows. Remember, if the password is incorrect, JDBC driver error may still occur. DB Setting Connection