Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.3.2
-
None
-
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
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
catch (Exception e) {
}
}
@After
public void tearDown() {
try
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())
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())
resultSet.close();
preparedStatement.close();
}
}