Here you can find the source of getTinyIntTypeString(Connection conn)
public static String getTinyIntTypeString(Connection conn) throws SQLException
//package com.java2s; /* ***** BEGIN LICENSE BLOCK ***** * * This file is part of Weave./*from w w w.j av a 2s . co m*/ * * The Initial Developer of Weave is the Institute for Visualization * and Perception Research at the University of Massachusetts Lowell. * Portions created by the Initial Developer are Copyright (C) 2008-2015 * the Initial Developer. All Rights Reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. * * ***** END LICENSE BLOCK ***** */ import java.sql.Connection; import java.sql.SQLException; public class Main { public static String MYSQL = "MySQL"; public static String SQLITE = "SQLite"; public static String POSTGRESQL = "PostgreSQL"; public static String SQLSERVER = "Microsoft SQL Server"; public static String ORACLE = "Oracle"; public static String getTinyIntTypeString(Connection conn) throws SQLException { String dbms = getDbmsFromConnection(conn); if (dbms.equals(ORACLE)) return "NUMBER(1,0)"; if (dbms.equals(POSTGRESQL)) return "SMALLINT"; // mysql, sqlserver return "TINYINT"; } public static String getDbmsFromConnection(Connection conn) { try { String dbms = conn.getMetaData().getDatabaseProductName(); for (String match : new String[] { ORACLE, SQLSERVER, MYSQL, SQLITE, POSTGRESQL }) if (dbms.equalsIgnoreCase(match)) return match; return dbms; } catch (SQLException e) { return ""; } } }