[CONJ-791] Using CallableStatement.getTimestamp() can't get data correctly Created: 2020-05-19  Updated: 2020-06-08  Resolved: 2020-06-08

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: 2.6.0
Fix Version/s: 2.6.1

Type: Bug Priority: Critical
Reporter: Chow King Tak Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

MariaDB 10.4.7, RHEL 7


Attachments: Java Source File TestGetDateTime.java     Java Source File TestGetTimestamp.java     File test_sp.sql    

 Description   

I have a SP as follows. It simply sets the output parameters to a fix value.

DELIMITER $$

DROP PROCEDURE IF EXISTS `test_SP` $$
CREATE PROCEDURE `test_SP`(
IN para1 BIGINT,
IN para2 nvarchar(1000),

OUT para3 NVARCHAR(10),
OUT para4 NVARCHAR(80),
OUT para5 NVARCHAR(80),

OUT para6 datetime,
OUT para7 datetime,
OUT para8 datetime,
OUT para9 datetime

)
BEGIN

SET para3 := 'PARAM 3';
SET para4 := 'PARAM 4';
SET para5 := 'PARAM 5';

SET para6 := '2006-01-01 01:01:16';
SET para7 := '2007-02-02 02:02:17';
SET para8 := '2008-03-03 03:03:18';
SET para9 := '2009-09-22 13:45:19';

END $$
DELIMITER ;

I have a Java program (see TestGetDateTime.java attached) to run the SP and retrieve the datetime values using getDate() and getTime(). All output parameter values can be retreived correctly as follows:

param3=PARAM 3
param4=PARAM 4
param5=PARAM 5
param6=2006-01-01 01:01:16
param7=2007-02-02 02:02:17
param8=2008-03-03 03:03:18
param9=2009-09-22 13:45:19

Then I have a same Java program (see TestTimestamp.java), but using getTimestamp() instead to get the datetime values. It fails to get all output parameters and the datetime values are incorrect (see param6 & param7) as follows:

param3=PARAM 3
param4=PARAM 4
param5=PARAM 5
param6=2008-03-03 03:03:18.0
param7=2009-09-22 13:45:19.0
java.sql.SQLDataException: No such column: 8
at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.checkObjectRange(SelectResultSet.java:630)
at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getTimestamp(SelectResultSet.java:1124)
at org.mariadb.jdbc.CallableProcedureStatement.getTimestamp(CallableProcedureStatement.java:364)
at TestGetTimestamp.main(TestGetTimestamp.java:53)

However, I have tried the MySQL Connector/J, there is no problem using getTimestamp(), I can get all values correctly.

Please investigate the problem.
The source of SP and Java are attached for reference.



 Comments   
Comment by Diego Dupin [ 2020-06-08 ]

Thanks for pointing that out.
This is corrected with this commit

and available in SNAPSHOT repository:

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>2.6.1-SNAPSHOT</version>
    </dependency>
</dependencies>

Generated at Thu Feb 08 03:18:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.