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

StringnativeSQL(String sql, boolean noBackslashEscapes)
native SQL
if (sql.indexOf('{') == -1)
    return sql;
StringBuffer escapeSequenceBuf = new StringBuffer();
StringBuffer sqlBuffer = new StringBuffer();
char[] a = sql.toCharArray();
char lastChar = 0;
boolean inQuote = false;
char quoteChar = 0;
...
ObjectnewArrayOfType(int typeCode, int size)
Create a new array of the specified type and size.
return newArrayOfType(typeCode, size, null);
TnewInstance(Class clazz, Object... params)
new Instance
try {
    if (params == null || params.length == 0) {
        return clazz.newInstance();
    } else {
        for (Constructor<?> ctor : clazz.getConstructors()) {
            if (ctor.getParameterTypes().length == params.length) {
                int paramIndex = 0;
                for (Class<?> paramType : ctor.getParameterTypes()) {
...
Listparse(String txt, int level)
parse
ArrayList list = new ArrayList();
String quotesChars = getQuotesChars(level);
String outerQuotes = getQuotesChars(level - 1);
if (!txt.startsWith(outerQuotes + "(") && !txt.endsWith(outerQuotes + ")")) {
    throw new RuntimeException("Not a valid construct for a Row");
} else {
    txt = txt.substring(outerQuotes.length() + 1);
    txt = txt.substring(0, txt.length() - outerQuotes.length() - 1);
...
StringprettyPrint(Object obj)
Helper method
StringBuilder sb = new StringBuilder();
if (obj == null) {
    sb.append("NULL");
} else if (obj instanceof Blob) {
    sb.append(formatLogParam((Blob) obj));
} else if (obj instanceof Clob) {
    sb.append(formatLogParam((Clob) obj));
} else if (obj instanceof Ref) {
...
StringreadAscii(Clob clob, String defaultValue)
read Ascii
if (clob == null) {
    return defaultValue;
InputStream is = null;
try {
    int length = (int) clob.length();
    if (length == 0) {
        return defaultValue;
...
List>readMapListBySQL(String fileDir, String sql, List headers, List headerTypes)
read Map List By SQL
List<Map<String, Object>> lists = new ArrayList<Map<String, Object>>();
StringBuilder headerLine = new StringBuilder();
StringBuilder headerLineTypes = new StringBuilder();
int headerSize = headers.size();
for (int i = 0; i < headerSize - 1; i++) {
    headerLine.append(headers.get(i));
    headerLine.append(',');
    headerLineTypes.append(headerTypes.get(i));
...
ObjectreadObject(DataInput in, int sqlType)
read Object
switch (sqlType) {
case Types.VARCHAR:
    return in.readUTF();
case Types.FLOAT:
    return Float.valueOf(in.readFloat());
case Types.DOUBLE:
    return Double.valueOf(in.readDouble());
case Types.BOOLEAN:
...
StringresolveEscapes(String escaped, boolean noBackslashEscapes)
resolve Escapes
if (escaped.charAt(0) != '{' || escaped.charAt(escaped.length() - 1) != '}')
    throw new SQLException("unexpected escaped string");
int endIndex = escaped.length() - 1;
if (escaped.startsWith("{fn ")) {
    String resolvedParams = replaceFunctionParameter(escaped.substring(4, endIndex));
    return nativeSQL(resolvedParams, noBackslashEscapes);
} else if (escaped.startsWith("{oj ")) {
    return nativeSQL(escaped.substring(4, endIndex), noBackslashEscapes);
...
voidsetFieldValue(Object oBean, String sFieldName, Object oValue)
set Field Value
if (oBean == null) {
    throw new RuntimeException("setFieldValue : bean instance is null ");
if (sFieldName == null) {
    throw new RuntimeException("setFieldValue : field name is null ");
String sFieldName2 = sFieldName.trim();
char cFirstChar = sFieldName2.charAt(0);
...