Search code examples
mysqlweka

Cannot connect to MySQL with Weka


I am trying to connect a database to Weka 3.6.13 in Linux Elementary OS.

First, I had a problem with JDBC connection, solved by this answer changing the /usr/bin/weka file.

Now, when I load the database, this error comes:

Unknown data type: INT. Add entry in weka/experiment/DatabaseUtils.props.

However, I am trying to use explorer only, this file doesn't even exists in my installation.

I installed via sudo apt install weka.

What should I do?

enter image description here


Solution

  • Look inside the directory where your weka.jar file resides, and check if there exists a file called DatabaseUtils.props.

    The Weka wiki says:

    Weka only looks for the DatabaseUtils.props file. If you take one of the example files listed above, you need to rename it first.

    My file is different I think the actual name does not really matter, it's the filename extension that matters.

    In my version of this file there is a section that looks like this:

    ... (snip...
    # mysql-conversion / type-mappings
    CHAR=0
    TEXT=0
    VARCHAR=0
    STRING=0
    LONGVARCHAR=9
    BINARY=0
    VARBINARY=0
    LONGVARBINARY=9
    BIT=1
    BOOL=1
    NUMERIC=2
    DECIMAL=2
    FLOAT=2
    DOUBLE=2
    TINYINT=3
    SMALLINT=4
    #SHORT=4
    SHORT=5
    INTEGER=5
    INT=5
    BIGINT=6
    LONG=6
    REAL=7
    DATE=8
    TIME=10
    TIMESTAMP=11
    
    #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
    

    If you do a google search for this file, another guy has posted his on github. The weka Wiki or SVN/Git-Repo might also list an offfical version somewhere (cannot find it right now), or you can open your weka.jar file as a zip file and extract the .props file (/src/main/java/weka/experiment/DatabaseUtils.props.mysql).

    In any case, Mysql exists in many different versions, and I think you can even switch the query engine inside mysql. So I cannot express any guarantees that any of these 2 .props files shown here really work for you. You should experiment a bit.