Mariadb: jdbc: setTimestamp truncates milliseconds

It seems to me that milliseconds are truncated if I insert them into my mariadb using the preparedStatement. Googling this was not successful, I found many similar problems that are either resolved or not applied. But it's hard for me to believe that I'm the only one who has this problem, so I wanted to ask here first before posting the error to mariadb. The code is very simple:

Table:

create table tt (id decimal(10), create_time timestamp(6) default 0);
or
create table tt (id decimal(10), create_time datetime(6) default 0);

Javacode:

Class.forName("org.mariadb.jdbc.Driver");
Connection conn = DriverManager.getConnection(DB_URL,"root","abc");
Statement insert1 = conn.createStatement();
insert1.execute("insert into tt (id, create_time) values (1,'2013-07-18 13:44:22.123456')");
PreparedStatement insert2 = conn.prepareStatement(
  "insert into tt (id, create_time) values (?,?)");
insert2.setInt(1, 2);
insert2.setTimestamp(2, new Timestamp(1273017612999L));
insert2.execute();

Output on my DOS console:

MariaDB [duc]> select * from tt;
+------+----------------------------+
| id   | create_time                |
+------+----------------------------+
|    1 | 2013-07-18 13:44:22.123456 |
|    2 | 2010-05-05 02:00:12.000000 |
+------+----------------------------+
2 rows in set (0.00 sec)

==> Milliseconds are lost for id = 2.

Does this sound like a mistake? Or did I do something wrong?

OS: windows7, 64 bit MariaDB version: 10.0.12 JDBC connector: 1.1.7 (mariadb) OR 5.1.32 (mysql)

I tested the same code in an Oracle database: milliseconds are inserted.

Thanks for any help ...

: mariaDB: https://mariadb.atlassian.net/browse/CONJ-107

+4
2

"useFractionalSeconds" JDBC MariaDB. , "jdbc: mariadb://127.0.0.1: 3306/somedb? UseFractionalSeconds = true".

(IMHO , , .)

+7

. MariaDB 10.0.13 Windows 8 Ubuntu 14.04. Windows MySQL 5.6.13 .

0

All Articles