Saturday, October 31, 2009

mysql-java-connector: ResultSet getObject failure on Timestamp column if null

I had strange situation working with ResultSet when fetching Timestamp column from MyTable.

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

Connection connection = DriverManager.getConnection(
"username", "password");

Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("SELECT timestamp_column FROM mytable");

while( {

The cause of the failure was due to null value in timestamp_column !

The solution suggested about (zeroDateTimeBehavior=convertToNull) in the article, helped me overcome the failure.

All you need to do is:
Connection connection = DriverManager.getConnection(
"username", "password");

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?