Developing ibm informix driver - timezone problems

Hi I’m busy writing the clj’s for building an informix.metabase.jar.
so far I succeeded in connecting the informix database to metabase, as well as being able to do native queries and some questions simple questions with filters.
The major problem is the integration of database-fields with the data type of dates and datetimes.
As informix does not support time zone, this is very tricky.

As I understand, metabase uses the jdbc-driver (in my case ifxjdbc.jar) to fetch a Connection for a database with session time zone set to timezone-id (if supported by the driver.) The default implementation:

  1. Calls util fn datasource to get a c3p0 connection pool DataSource
  2. Calls .getConnection() the normal way
  3. Executes set-timezone-sql if implemented by the driver.

So my questions are:
1 - Does the util fn ‘datasource’ call a ‘set-timezone’?
2 - How can I make Metabase use the LocalDateTime as default and not the ZonedDateTime?
3 - Is it even possible for Metabase to connect to a Database that does not support “timestamps with timezone”?

Any help appreciated.

{
“browser-info”: {
“language”: “de”,
“platform”: “Linux x86_64”,
“userAgent”: “Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0”,
“vendor”: “”
},
“system-info”: {
“file.encoding”: “UTF-8”,
“java.runtime.name”: “OpenJDK Runtime Environment”,
“java.runtime.version”: “1.8.0_262-b10”,
“java.vendor”: “Oracle Corporation”,
“java.vendor.url”: “http://java.oracle.com/”,
“java.version”: “1.8.0_262”,
“java.vm.name”: “OpenJDK 64-Bit Server VM”,
“java.vm.version”: “25.262-b10”,
“os.name”: “Linux”,
“os.version”: “3.10.0-1062.18.1.el7.x86_64”,
“user.language”: “de”,
“user.timezone”: “Europe/Berlin”
},
“metabase-info”: {
“databases”: [
“postgres”,
“ibminformix”,
“oracle”,
“h2”
],
“hosting-env”: “unknown”,

I found the solution, because the ifxjdbc driver for informix does not fully support the java.time classes it has to use legacy-classes.
“Implementations of sql-jdbc.execute methods for JDBC drivers that aren’t fully JDBC 4.2 compliant or otherwise don’t fully support the new JSR-310 java.time classes. Drivers with ::use-legacy-classes-for-read-and-set as a parent will use these implementations instead of the defaults.”
so the ibm informix driver must be told:
(driver/register! :ibminformix, :parent #{:sql-jdbc ::legacy/use-legacy-classes-for-read-and-set})
this works.
Unfortunately another problem occurs because of the Mega sync performance improvements #13746.
see: [https://github.com/metabase/metabase/pull/13746 ]

Weel I’ll keep on it.

1 Like

Update as of today the code for the driver is published on github:

Feedback is welcome.

1 Like

Would it be possible to get the jar so I could give it a try?
Thanks!
Roberto

Hi Roberto,
I published the jar-file on Github:


Camiel

Hello Camiel,
I was meaning if I could get the compiled jar for the metabase to informix driver, sorry if I was not clear.
I cannot compile from my PC (and don't have the knowledge). If I could get the "informix.metabase-driver.jar" directly would be appreciated.
Regards,
Roberto

go to:


and you can download the .jar-file from there.
Camiel

Thanks, I can see the IBMInformix element in the list of available connectors but then, when I try to set up the connection, I get this:

Attempting to call unbound fn: #'metabase.util.ssh/include-ssh-tunnel

[0a15f1b5-fb77-48a1-902b-3cea63bf361c] 2021-07-26T16:08:43+02:00 INFO metabase.driver.impl Registered abstract driver :metabase.driver.sql-jdbc.execute.legacy-impl/use-legacy-classes-for-read-and-set  
[0a15f1b5-fb77-48a1-902b-3cea63bf361c] 2021-07-26T16:08:43+02:00 INFO metabase.driver.impl Registered driver :ibminformix (parents: [:sql-jdbc :metabase.driver.sql-jdbc.execute.legacy-impl/use-legacy-classes-for-read-and-set]) 
[0a15f1b5-fb77-48a1-902b-3cea63bf361c] 2021-07-26T16:08:43+02:00 DEBUG metabase.plugins.jdbc-proxy Registering JDBC proxy driver for com.informix.jdbc.IfxDriver...
[0a15f1b5-fb77-48a1-902b-3cea63bf361c] 2021-07-26T16:08:43+02:00 ERROR metabase.driver.util Database connection error
java.lang.IllegalStateException: Attempting to call unbound fn: #'metabase.util.ssh/include-ssh-tunnel
	at clojure.lang.Var$Unbound.throwArity(Var.java:45)
	at clojure.lang.AFn.invoke(AFn.java:32)
	at metabase.driver.ibminformix$fn__468.invokeStatic(ibminformix.clj:193)
	at metabase.driver.ibminformix$fn__468.invoke(ibminformix.clj:192)
	at clojure.lang.MultiFn.invoke(MultiFn.java:234)
	at metabase.driver.util$can_connect_with_details_QMARK_$fn__29853.invoke(util.clj:34)
	at metabase.util$do_with_timeout$fn__15630.invoke(util.clj:346)
	at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
[0a15f1b5-fb77-48a1-902b-3cea63bf361c] 2021-07-26T16:08:43+02:00 INFO metabase.driver.impl Initializing driver :metabase.driver.sql-jdbc.execute.legacy-impl/use-legacy-classes-for-read-and-set...
[0a15f1b5-fb77-48a1-902b-3cea63bf361c] 2021-07-26T16:08:43+02:00 ERROR metabase.api.database Cannot connect to Database

@rpm75 Always include your Metabase version, since drivers need to be compatible.

@com Have a look here for a fix for the SSH:
https://github.com/mat02/metabase-firebird-driver/commit/90e797b42e6832df5cdafa466d2f390a0703db48

@flamber -> Metabase v0.40.1 (ed8f9c8 release-x.40.x)

tested with 1.37 and worked