Here you can find the source of getJDBCTypeForNamedType(String aTypeName)
Parameter | Description |
---|---|
aTypeName | a type name to use to lookup a JDBC datatype |
public static int getJDBCTypeForNamedType(String aTypeName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at/*from w w w . j a v a2 s .c o m*/ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { public static final String TYPENAME_BIGINT = "BIGINT"; public static final String TYPENAME_BLOB = "BLOB"; public static final String TYPENAME_CHAR = "CHAR"; public static final String TYPENAME_CHARACTER = "CHARACTER"; public static final String TYPENAME_CHARACTER_VARYING = "CHARACTER VARYING"; public static final String TYPENAME_CLOB = "CLOB"; public static final String TYPENAME_DATALINK = "DATALINK"; public static final String TYPENAME_DATE = "DATE"; public static final String TYPENAME_DBCLOB = "DBCLOB"; public static final String TYPENAME_DEC = "DEC"; public static final String TYPENAME_DECIMAL = "DECIMAL"; public static final String TYPENAME_DOUBLE = "DOUBLE"; public static final String TYPENAME_DOUBLE_PRECISION = "DOUBLE PRECISION"; public static final String TYPENAME_GRAPHIC = "GRAPHIC"; public static final String TYPENAME_INT = "INT"; public static final String TYPENAME_INTEGER = "INTEGER"; public static final String TYPENAME_LONG_VARCHAR = "LONG VARCHAR"; public static final String TYPENAME_LONG_VARGRAPHIC = "LONG VARGRAPHIC"; public static final String TYPENAME_NUMERIC = "NUMERIC"; public static final String TYPENAME_REAL = "REAL"; public static final String TYPENAME_SMALLINT = "SMALLINT"; public static final String TYPENAME_TIME = "TIME"; public static final String TYPENAME_TIMESTAMP = "TIMESTAMP"; public static final String TYPENAME_VARBINARY = "VARBINARY"; public static final String TYPENAME_VARCHAR = "VARCHAR"; public static final String TYPENAME_VARGRAPHIC = "VARGRAPHIC"; /** * Gets the JDBC datatype identifier corresponding to the given named datatype. * This is for use with the datatype names returned from the FunctionHelper. * Note: there is probably a utility somewhere else that does this. If so, * we can get rid of this method. * * @param aTypeName a type name to use to lookup a JDBC datatype * @return int a JDBC type identifier. */ public static int getJDBCTypeForNamedType(String aTypeName) { int jdbcTypeID = 0; // The types that appear most frequently in the FunctionHelper parameter // lists are checked first. if (aTypeName.equalsIgnoreCase(TYPENAME_INTEGER) || aTypeName.equalsIgnoreCase(TYPENAME_INT)) { jdbcTypeID = java.sql.Types.INTEGER; /* 4 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_DECIMAL) || aTypeName.equalsIgnoreCase(TYPENAME_DEC) || aTypeName.equalsIgnoreCase(TYPENAME_NUMERIC) || aTypeName.equalsIgnoreCase("NUM")) { //$NON-NLS-1$ jdbcTypeID = java.sql.Types.DECIMAL; /* 3 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_VARCHAR) || aTypeName.equalsIgnoreCase(TYPENAME_CHARACTER_VARYING) || aTypeName.equalsIgnoreCase("CHAR VARYING")) { //$NON-NLS-1$ jdbcTypeID = java.sql.Types.VARCHAR; /* 12 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_DOUBLE) || aTypeName.equalsIgnoreCase(TYPENAME_DOUBLE_PRECISION)) { jdbcTypeID = java.sql.Types.DOUBLE; /* 8 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_CHARACTER) || aTypeName.equalsIgnoreCase(TYPENAME_CHAR)) { jdbcTypeID = java.sql.Types.CHAR; /* 1 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_SMALLINT)) { jdbcTypeID = java.sql.Types.SMALLINT; /* 5 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_BIGINT)) { jdbcTypeID = java.sql.Types.BIGINT; /* -5 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_REAL)) { jdbcTypeID = java.sql.Types.REAL; /* 7 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_DATE)) { jdbcTypeID = java.sql.Types.DATE; /* 91 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_TIME)) { jdbcTypeID = java.sql.Types.TIME; /* 92 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_TIMESTAMP)) { jdbcTypeID = java.sql.Types.TIMESTAMP; /* 93 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_LONG_VARCHAR)) { jdbcTypeID = java.sql.Types.LONGVARCHAR; /* -1 */ } // Graphic types map to JDBC char types. else if (aTypeName.equalsIgnoreCase(TYPENAME_GRAPHIC)) { jdbcTypeID = java.sql.Types.CHAR; /* 1 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_VARGRAPHIC)) { jdbcTypeID = java.sql.Types.VARCHAR; /* 12 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_LONG_VARGRAPHIC)) { jdbcTypeID = java.sql.Types.LONGVARCHAR; /* -1 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_VARBINARY)) { jdbcTypeID = java.sql.Types.VARBINARY; /* -3 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_DATALINK)) { jdbcTypeID = java.sql.Types.DATALINK; /* 70 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_BLOB)) { jdbcTypeID = java.sql.Types.BLOB; /* 2004 */ } else if (aTypeName.equalsIgnoreCase(TYPENAME_CLOB)) { jdbcTypeID = java.sql.Types.CLOB; /* 2005 */ } // DBCLOB maps to JDBC CLOB type. else if (aTypeName.equalsIgnoreCase(TYPENAME_DBCLOB)) { jdbcTypeID = java.sql.Types.CLOB; /* 2005 */ } return jdbcTypeID; } }