Bug 153678 - support JDBC 4.2 types TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE
Summary: support JDBC 4.2 types TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.3.7.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-16 23:49 UTC by prrvchr
Modified: 2023-07-29 00:02 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description prrvchr 2023-02-16 23:49:40 UTC
Description:
Hi all,

I try to integrate more JDBC driver in my jdbcDriverOOo extension:
- H2 database
- JDBC SQLite

To achieve this, is it possible to launch LibreOffice Base in debug mode so that it displays any error when opening the database as well as when opening and/or editing tables?

Thanks for your advices.

Actual Results:
Hi all,

I try to integrate more JDBC driver in my jdbcDriverOOo extension:
- H2 database
- JDBC SQLite

To achieve this, is it possible to launch LibreOffice Base in debug mode so that it displays any error when opening the database as well as when opening and/or editing tables?

Thanks for your advices.

Expected Results:
Hi all,

I try to integrate more JDBC driver in my jdbcDriverOOo extension:
- H2 database
- JDBC SQLite

To achieve this, is it possible to launch LibreOffice Base in debug mode so that it displays any error when opening the database as well as when opening and/or editing tables?

Thanks for your advices.


Reproducible: Always


User Profile Reset: No

Additional Info:
Hi all,

I try to integrate more JDBC driver in my jdbcDriverOOo extension:
- H2 database
- JDBC SQLite

To achieve this, is it possible to launch LibreOffice Base in debug mode so that it displays any error when opening the database as well as when opening and/or editing tables?

Thanks for your advices.
Comment 1 Julien Nabet 2023-02-17 07:07:40 UTC
There must some other way but to have max info, I'd suggest to build yourself LO by following https://wiki.documentfoundation.org/Development/BuildingOnLinux + adding --enable-dbgutil in autogen.input
Comment 2 prrvchr 2023-02-20 13:37:40 UTC
Thanks for the advice, I'll try it soon.

It would be nice if the UNO and Base API could handle the JDBC 4.2 types: TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE. 

I arrive with the latest version of jdbcDriverOOo (which I haven't pushed yet) to get or assign (getObject and setObject) a com.sun.star.util.DateTimeWithTimezone or a com.sun.star.util.TimeWithTimezone.

It would be nice if com.sun.star.sdbc.DataType could list missing types and Base could handle them.
Comment 3 Julien Nabet 2023-02-20 21:04:17 UTC
(In reply to prrvchr from comment #2)
> Thanks for the advice, I'll try it soon.
Great! :-)
 
> It would be nice if the UNO and Base API could handle the JDBC 4.2 types:
> TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE.
This page https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/jdbc_42.html doesn't mention them. Did I miss something?

> ... 
> It would be nice if com.sun.star.sdbc.DataType could list missing types and
> Base could handle them.
I suppose we need more than quote the new types, for example how to deal with them for each driver (see connectivity/source/drivers/ subdirs)
Comment 4 prrvchr 2023-02-21 10:45:51 UTC
> This page https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/jdbc_42.html
> doesn't mention them. Did I miss something?

I do not know exactly the version of JDBC which included these two new types but they can be found in the documentation of Java 8 or JDBC 4.2:
- https://docs.oracle.com/javase/8/docs/api/constant-values.html#java.sql.Types.TIME_WITH_TIMEZONE
- https://docs.oracle.com/javase/8/docs/api/constant-values.html#java.sql.Types.TIMESTAMP_WITH_TIMEZONE

But I know that the databases supporting the system versioning (or temporal table) like HsqlDB since its version 2.5.X uses two columns (ROWSTART and ROWEND) of type TIMESTAMP_WITH_TIMEZONE to carry out this management.

> I suppose we need more than quote the new types, for example how to deal with them for
> each driver (see connectivity/source/drivers/ subdirs)

In Java 9 (and later) the methods to assign a column (setter) of one of these two types are:
- setObject(Interger, java.time.OffsetDateTime or OffsetTime)
- setString(Interger, String)
- setTimestamp(Interger, java.sql.Timestamp, java.util.Calendar)
  setTime(Interger, java.sql.Time or Time, java.util.Calendar)

The methods to get a column (getter):
- java.time.OffsetDateTime or OffsetTime getObject(Interger)
- String getString(Interger)
- java.sql.Timestamp getTimestamp(Interger, java.util.Calendar)
  java.sql.Time getTime(Interger, java.util.Calendar)

The getter and setter getObject and setObject are normally the recommended methods for this type of data. And it is possible to easily convert java.time.OffsetDateTime to a com.sun.star.util.DateTimeWithTimezone (idem for java.time.OffsetTime) for and vice versa.

The getter and setters getString and setString are the simplest methods. If the driver (jdbcDriverOOo) maps these two new types to type com.sun.star.sdbc.DataType.VARCHAR then Base is able to display and update columns of this type. This display will depend on the conversion performed by the database level.

The getter and setter getTimestamp / setTimestamp (and getTime / setTime) seem deprecated.

On the other hand, for the creation of a table (CREATE TABLE ...) the type TIMESTAMP WITH TIMEZONE requires lines of code dedicated to this type since the precision must be inserted in the type: ie: TIMSTAMP(9) WITH TIME ZONE...

Hoping to have answered your questions.
Comment 5 prrvchr 2023-02-21 15:19:38 UTC
To be more precise, if I look at the java code coming from OpenOffice (openoffice/main/connectivity/java) and which is the one I use for the jdbcDriverOOo driver and it seems to be taken from C code, the changes to be made are:
DbTools.java createStandardColumnPart()

This method is called for creating tables and adding a column to a table in Base, so respectively:
- com.sun.star.sdbcx.XAppend of com.sun.star.sdbcx.Container service provided by the com.sun.star.sdb.Connection.getTables() method.
- com.sun.star.sdbcx.XAlterTable com.sun.star.sdbcx.Table service

It is also necessary to take into account the display, the addition and the edition of the contents of the tables in Base. Two solutions can be considered:
- Treat the contents of these columns as String: easy but the display will depend on the conversion performed by the underlying database.
- Use, getObject setObject and updateObject, getter and setter, convert to text format taking locale into account.
I don't know how Base goes about processing a TIMESTAMP.
Comment 6 Julien Nabet 2023-02-21 18:10:07 UTC
Since I don't know more about this, I'll uncc myself.

If you want to submit patches for LO, you can follow https://wiki.documentfoundation.org/Development/GetInvolved.
Comment 7 prrvchr 2023-07-29 00:02:51 UTC
Does anyone know where to look to find out how base displays and saves the contents of a table in edit mode?