ResultSet of PreparedStatement return NULL When TIME column value=00:00:00

Description

When TIME type column value=00:00:00, using Statement is OK and return 00:00:00.
But using PreparedStatement is NOT OK and return NULL.

// DDL & DML
create table BILLING.TIME_PERIOD (
ID int unsigned NOT NULL,
START time NOT NULL,
END time NOT NULL,
PRIMARY KEY (ID)
) engine=InnoDB DEFAULT CHARSET=big5

insert into time_period(id, start, end) values(1, '00:00:00', '08:00:00');

// Test Code
package com.cc.test

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class MariaDbJdbcDriverTest {

private final String URL = "jdbc:mariadb://localhost:3306/billing";
private final String USER = "root";
private final String PWD = "root";
private Connection connection;

@Before
public void setUp() {
try {
DriverManager.registerDriver(new org.mariadb.jdbc.Driver());
connection = DriverManager.getConnection(URL, USER, PWD);
connection.setAutoCommit(false);
} catch (Exception e) {
}
}

@After
public void tearDown() {
try {
connection.commit();
connection.close();
} catch (Exception e) {
}
}

@Test
public void testStatement() throws Exception {
final String sql = "SELECT id, start, end FROM time_period WHERE id=1;";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
System.out.println(resultSet.getInt(1));
System.out.println(resultSet.getTime(2));//OK and return 00:00:00
System.out.println(resultSet.getTime(3));
}
resultSet.close();
statement.close();
}

@Test
public void testPreparedStatement() throws Exception {
final String sql = "SELECT id, start, end FROM time_period WHERE id=?;";
PreparedStatement preparedStatement = connection.prepareStatement(sql);
preparedStatement.setInt(1, 1);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
System.out.println(resultSet.getInt(1));
System.out.println(resultSet.getTime(2));//NOT OK retrun NULL when value=00:00:00
System.out.println(resultSet.getTime(3));
}
resultSet.close();
preparedStatement.close();
}

}

Environment

OS : Windows XP 5.01. 2600 Service Pack 3
DB : MariaDB 10.1.9
JDBC driver : mariadb-java-client 1.3.2
JDK : 1.8.0_66

Assignee

Diego Dupin

Reporter

Chun Chong

Labels

None

Components

Fix versions

Affects versions

Priority

Major
Configure