Adel Adel - 4 months ago 12
Java Question

Embedding MySQL in java desktop with mysql/connector/mxj

I'm using Embedding MySQL database in my desktop application and using MySQL/connector/MXJ (I know that has been discontinued by Mysql guys).

It's a good way to start MySQL in windows platform without causing errors.

My question is how can I set Server Options using my.ini (MySQL/bin/my.ini)? For example, I add

innodb_force_recovery = 6
into my.ini but when I use
getServerOptions()
I get

innodb-force-recovery 0


Is there any other why to set server options ?

Thanks

Answer

I fix the problem by including connector/MXJ source code directly into my project, after that I mark some change on MysqldResource.java

String[] constructArgs(Map mysqldArgs) {
    List strs = new ArrayList();
    strs.add(utils.files().getPath(getMysqldFilePointer()));

    //The magic happens here 
    strs.add("--defaults-file=mysql\\my.ini");
    if (isWindows()) {
        strs.add("--console");
    }
    Iterator it = mysqldArgs.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Map.Entry) it.next();
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();
        StringBuffer buf = new StringBuffer("--");
        buf.append(key);
        if (value != null) {
            buf.append("=");
            buf.append(value);
        }
        strs.add(buf.toString());
    }

    return utils.str().toStringArray(strs);
}