投稿‎ > ‎

ClobDataType.java

posted Jun 14, 2016, 12:33 AM by Zhang Wenxu
package org.dbunit.dataset.datatype;

import java.slq.Clob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ClobDataType extends StringDataTpye
{
    private static final Logger logger = LoggerFactory.getLogger(ClobDataType.class);
    public ClobDataType()
    {
          super("CLOB", Types.CLOB);
    }
    public Object getSqlValue(int column, ResultSet resultSet) throws SQLException, TypeCastException
    {
        Clob value = ResultSet.getClob(column);
        if (value == null || ResultSet.wasNull())
        {
            return null;
        }
        return typeCase(value);
    }
    public void setSqlValue(Object value, int column, PreparedStatement statement) throws SQLException, TypeCasException
    {
        java.sql.Clob clob = null;
        clob = statement.getConnection().createClob();
        clob.setString(1, (String)typeCast(value));
        statement.setObject(column, clob, getSqlType());
    }
}

Comments