Java SQL Type createSqlDataType(@Nonnull final String javaDataType)

Here you can find the source of createSqlDataType(@Nonnull final String javaDataType)

Description

Create the java.sql.Types type for the given Java datatype.

License

Open Source License

Parameter

Parameter Description
javaDataType the Java datatype to convert.

Return

the created java.sql.Types datatype created.

Declaration

public static String createSqlDataType(@Nonnull final String javaDataType) 

Method Source Code


//package com.java2s;
/*/*  w ww .  ja  v a2s .  c o  m*/
 * Copyright (C) 2016 uwe
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import javax.annotation.Nonnull;

public class Main {
    /**
     * Create the java.sql.Types type for the given Java datatype.
     *
     * @param javaDataType the Java datatype to convert.
     * @return the created java.sql.Types datatype created.
     */
    public static String createSqlDataType(@Nonnull final String javaDataType) {
        if ("boolean".equals(javaDataType) || "java.lang.Boolean".equals(javaDataType)) {
            return "java.sql.Types.BOOLEAN";
        } else if ("byte".equals(javaDataType) || "java.lang.Byte".equals(javaDataType)) {
            return "java.sql.Types.TINYINT";
        } else if ("short".equals(javaDataType) || "java.lang.Short".equals(javaDataType)) {
            return "java.sql.Types.SMALLINT";
        } else if ("int".equals(javaDataType) || "java.lang.Integer".equals(javaDataType)) {
            return "java.sql.Types.INTEGER";
        } else if ("long".equals(javaDataType) || "java.lang.Long".equals(javaDataType)) {
            return "java.sql.Types.BIGINT";
        } else {
            return "java.sql.Types.BINARY";
        }
    }
}

Related

  1. convertType(final int type)
  2. convertType(final int type, final String typeName)
  3. createAllTypesTable(Connection conn)
  4. createArrTypSql(String[] arr)
  5. createSignature(Method m)
  6. createTable2()
  7. createTestData()
  8. decodeJavaType(Object pType)
  9. deleteData(Connection conn)