Finally I’ve got it.
TLDR; Detailed description:
After I’ve tried about 200 combinations of “host params” and “key-values” in url, read all I’ve found about mariadb-connector-j (first this was about named pipes, later - about everything), forums, github sources etc, I’ve started to learn java (don’t need it at all but was forced by this problem). Write a .java/class that tries to connect to database, run that by "java -cp …: — when using mysql connector — all was ok, when using mariadb — always something went wrong.
Then I tried to connect directly with mariadb’s mysql --user=* --password=* --protocol=PIPE --socket=MySQL — and I’ve got successful connection, this was understandable, because I’ve got successful connection through mariadb-connector-odbc. Returned to java…
Installed IntelliJ IDEA to little speedup this "save, repeat java -cp etc - and tried a ton of parameter combinations and finally got the connection. All was simple. I’ve used url from openfire.xml (&
) but url in my .java/.class must be &
, only needed parameter is pipe=MySQL (MySQL is the default socket/named-pipe name for a channel, I’ve commented #socket=… in my mariadb.ini).
Finally I’ve got a successfull connection with java connector outside of openfire (before today I’ve always tried to connect by editing openfire.xml’s url and starting/stopping windows service. This was my biggest mistake — I’ve thought that openfire was ok but problem was with mariadb-connector-java (because when url was jdbc:mysql with mysql driver all was ok).
When I’ve got 100% working url (jdbc:mariadb:///openfire?pipe=MySQL) I’ve applied it in openfire.xml and… got a first error — because this is xml (I’ve found it later) all &
must be &
's - ok, changed.
Now it is <serverURL>jdbc:mariadb:///openfire?pipe=MySQL&rewriteBatchedStatements=true</serverURL>
Starting service and… openfire didn’t connect.
org.jivesoftware.database.DbConnectionManager - connect: The address can't be null
Next was dances with drums - //./, //localhost/ and so on — result the same “address can’t be null”.
jdbc:mariadb://./openfire?pipe=MySQL&rewriteBatchedStatements=true
jdbc:mariadb://localhost/openfire?pipe=MySQL&rewriteBatchedStatements=true
java/windows classpath is strange for me (I think it’s the bug):
default is CLASSPATH=.;JAVA_HOME\lib
when I’ve added path where my .jar’s are (mariadb/mysql connectors, jna-platform [unneeded totally!], jna) in the way as default written, for example CLASSPATH=.;JAVA_HOME\lib;C:\JAVADIR
then java didn’t get this files (checked with sysinternals process monitor). But when I’ve added an asterisk CLASSPATH=.;JAVA_HOME\lib;C:\JAVADIR\*
then java successfully read and use .jar’s. So the default JAVA_HOME\lib is not working at all.
When java get jna-5.13.0.jar additionally with mariadb-java-client-3.1.2 (at the moment of this post) connection was successful.
my java code to successfull connection to openfire database:
import java.sql.*;
class MariaDBCon {
public static void main(String args[]) {
try {
Class.forName("org.mariadb.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mariadb:///openfire?pipe=MySQL","user","password");
// ton of variants:
// Connection con = DriverManager.getConnection("jdbc:mariadb://address=(host=localhost)(protocol=pipe)(named-pipe=true)(namedpipe=true)(tcpip=0)(socket=MySQL)(path=MySQL)/?protocol=pipe&named-pipe=true&namedpipe=true&tcpip=0&socket=MySQL&path=MySQL","user","password");
try (Statement stmt = con.createStatement()) {
stmt.executeQuery("select * from openfire");
}
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
}