4
$\begingroup$

I used Mathematica to access the data of a MariaDB MySQL database. Within the version 12.0 it worked well on linux using the following code:

Needs["DatabaseLink`"]
conn = OpenSQLConnection["OpenHAB"];

I defined the connection properties successfully like this:

  • User Lever
  • MySQL(Connector/J)
  • com.mysql.jdbc.Driver
  • jdbc:mysql://
  • IP, port, username, password

After switching to Mathematica 12.2 everything works fine just after fresh installation.

After the second start of Mathematica the connection gets the following error:

KeyExistsQ::invrl: The argument Association[Flatten[JDBCDrivers[]/. JDBCDriver[Name->DatabaseLink`SQL`Private`name_,Driver->DatabaseLink`SQL`Private`driver_,Protocol->DatabaseLink`SQL`Private`protocol_,_,_,_]:>{DatabaseLink`SQL`Private`name->Association[Rule[<<2>>],Rule[<<2>>]]}]] is not a valid Association or a list of rules.

From the second start on I can not bring the connection back on line. If I use the assistant under

OpenSQLConnection[]

to delete the connection and to set it up again it will fail also. If I use the Test button within the assistant I get

Error:KeyExistQ::invrl

The only way to bring the connection back at least once is to uninstall Mathematica completely and do a fresh install. As this works until the next start of Mathematica it is not a very suitable for working.

Thanks

$\endgroup$

2 Answers 2

0
$\begingroup$

The KeyExistQ error is caused by a malformed JDBC configuration file. Unluckily the documentation on how to set up JDBC configuration files is no longer correct for 12.2.

A JDBC driver configuration is expected to have the five keys "Name", "Driver", "Protocol", "Version" and "Description" in the correct order, e.g.:

JDBCDriver[
    "Name" -> "Oracle(thin)",
    "Driver" -> "oracle.jdbc.driver.OracleDriver",
    "Protocol" -> "jdbc:oracle:thin:@",
    "Version" -> DatabaseLink`Information`$VersionNumber, 
    "Description" -> "Oracle Thin Driver"
]

In 12.3 (which ships with DatabaseLink 3.0.1) the issue has been partially fixed. Changing the order of the named keys in JDBCDriver however still triggers the KeyExistQ error.

$\endgroup$
3
$\begingroup$

Thanks for reporting this. Unfortunately, Mathematica 12.2 has this bug but this should be fixed by the newer paclet release.

For now, a workaround could be by using JDBC driver connection as below:

conn = Quiet[
  OpenSQLConnection[
   JDBC["com.mysql.jdbc.Driver", "jdbc:mysql://" <> "hostname"], 
   "Username" -> "user", "Password" -> "Password"]]
$\endgroup$
1
  • $\begingroup$ Thank you for your answer. I tested the workaround and it fixed the problem. Wolfram support suggested to do the same. $\endgroup$
    – Tschibi
    Commented Mar 3, 2021 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.