convert Sql Type to Java Type - Java java.sql

Java examples for java.sql:Timestamp

Description

convert Sql Type to Java Type

Demo Code


//package com.java2s;

import java.util.Date;

public class Main {


    public static Class<?> convertSqlType(String sqlType) {
        if (sqlType == null) {
            return String.class;
        }//from  ww w  .j av a  2  s .co  m
        if ("VARCHAR".equals(sqlType)) {
            return String.class;
        } else if ("TIMESTAMP".equals(sqlType)) {
            return Date.class;
        } else if ("INTEGER".equals(sqlType)) {
            return int.class;
        } else if ("VARBINARY".equals(sqlType)) {
            return byte[].class;
        }
        return String.class;
    }
}

Related Tutorials