Java Utililty Methods SQL Type

List of utility methods to do SQL Type

Description

The list of methods to do SQL Type are organized into topic(s).

Method

StringdecodeJavaType(Object pType)
This is a private helper method that will decode java types to the required SQL formatting.
StringBuffer mSQL = new StringBuffer();
if (null != pType) {
    if (pType instanceof String) {
        mSQL.append("'");
        mSQL.append(pType);
        mSQL.append("'");
    } else if (pType instanceof Timestamp) {
        mSQL.append(normalize((Timestamp) pType));
...
voiddeleteData(Connection conn)
Delete records from tables ISSUE_TYPES, DUMMYUSER and ISSUES.
executeFileSQL(conn, DELETE_SQL_FILE_PATH);
voiddeleteFromAllTables(Connection con)
delete From All Tables
for (String table : tables) {
    try (Statement statement = con.createStatement()) {
        statement.execute("DELETE FROM " + table);
ObjectdeserializeSQLTypesToJava(String sqltypename, String value)
deserialize SQL Types To Java
Class clazz = String.class;
String cleantypename = sqltypename.trim().toUpperCase();
if (mapSQLtypeNameToJavaClass.containsKey(cleantypename))
    clazz = mapSQLtypeNameToJavaClass.get(cleantypename);
if (Boolean.TYPE == clazz)
    return Boolean.parseBoolean(value);
else if (Byte[].class == clazz)
    return value.getBytes(Charset.forName("UTF-8"));
...
voiddumpTypes(Connection pConnection)
dump Types
try (ResultSet rs = pConnection.getMetaData().getTypeInfo()) {
    System.out.println(
            "TYPE_NAME,DATA_TYPE,PRECISION,LITERAL_PREFIX,LITERAL_SUFFIX,CREATE_PARAMS,NULLABLE,CASE_SENSITIVE,SEARCHABLE,UNSIGNED_ATTRIBUTE,FIXED_PREC_SCALE,AUTO_INCREMENT,LOCAL_TYPE_NAME,MINIMUM_SCALE,MAXIMUM_SCALE,SQL_DATA_TYPE,SQL_DATETIME_SUB,NUM_PREC_RADIX");
    while (rs.next() == true) {
        System.out.print(rs.getString(1));
        System.out.print(",");
        System.out.print(rs.getInt(2));
        System.out.print(",");
...
IntegerextractConstant(String typeName)
extract Constant
int lastDotPos = typeName.lastIndexOf(".");
if (lastDotPos < 1) {
    throw new IllegalArgumentException("Type constant is not member of " + Types.class.getName()
            + " and its name is not fully specified: " + typeName);
String className = typeName.substring(0, lastDotPos);
String fieldName = typeName.substring(lastDotPos + 1);
Class cls = Class.forName(className);
...
StringfillLogParams(String sql, Map logParams)
Returns sql statement used in this prepared statement together with the parameters.
StringBuilder result = new StringBuilder();
Iterator<Object> it = logParams.values().iterator();
boolean inQuote = false;
boolean inQuote2 = false;
char[] sqlChar = sql.toCharArray();
for (int i = 0; i < sqlChar.length; i++) {
    if (sqlChar[i] == '\'') {
        inQuote = !inQuote;
...
MethodfindMethod(Class returnType, Class parameterType)
find Method
for (Method method : ResultSet.class.getMethods()) {
    Class<?>[] parameterTypes = method.getParameterTypes();
    if (parameterTypes.length == 1 && parameterTypes[0].equals(parameterType)
            && returnType.equals(method.getReturnType()) && method.getName().startsWith("get")) {
        return method;
return null;
...
StringgetAntipodeForFunction(String base, int destType)
get Antipode For Function
if (base.startsWith("com.apatar.functions.String.data.")) {
    if ("com.apatar.functions.String.data.ToInt16TransformFunction".equals(base)
            || "com.apatar.functions.String.data.ToInt32TransformFunction".equals(base)
            || "com.apatar.functions.String.data.ToInt64TransformFunction".equals(base)
            || "com.apatar.functions.String.data.ToIntSingleTransformFunction".equals(base)
            || "com.apatar.functions.String.data.ToBooleanTransformFunction".equals(base)) {
        switch (destType) {
        case Types.BIGINT: 
...
int[]getArgTypes()
get Arg Types
return Arrays.copyOf(ARG_TYPES, ARG_TYPES.length);