Example usage for java.sql JDBCType INTEGER

List of usage examples for java.sql JDBCType INTEGER

Introduction

In this page you can find the example usage for java.sql JDBCType INTEGER.

Prototype

JDBCType INTEGER

To view the source code for java.sql JDBCType INTEGER.

Click Source Link

Document

Identifies the generic SQL type INTEGER .

Usage

From source file:com.thinkbiganalytics.discovery.util.ParserHelper.java

/**
 * Derive the corresponding data type from sample values
 *
 * @param values a list of string values
 * @return the JDBC data type/*from ww w  .j  ava2  s. c  o  m*/
 */
public static JDBCType deriveJDBCDataType(List<String> values) {

    JDBCType guess = null;
    if (values != null) {
        for (String v : values) {
            if (!StringUtils.isEmpty(v)) {
                JDBCType currentPass;
                try {
                    Integer.parseInt(v);
                    currentPass = JDBCType.INTEGER;
                } catch (NumberFormatException e) {
                    try {
                        Double.parseDouble(v);
                        currentPass = JDBCType.DOUBLE;
                    } catch (NumberFormatException ex) {
                        // return immediately for non-numeric case
                        return JDBCType.VARCHAR;
                    }
                }
                // If a double is encountered, use that type
                if (guess == null || currentPass == JDBCType.DOUBLE) {
                    guess = currentPass;
                }
            }
        }
    }
    return (guess == null ? JDBCType.VARCHAR : guess);
}

From source file:org.elasticsearch.xpack.qa.sql.rest.RestSqlTestCase.java

public void testBasicQueryWithParameters() throws IOException {
    String mode = randomMode();//from  www . ja v  a  2  s .c om
    index("{\"test\":\"foo\"}", "{\"test\":\"bar\"}");

    Map<String, Object> expected = new HashMap<>();
    expected.put("columns", Arrays.asList(columnInfo(mode, "test", "text", JDBCType.VARCHAR, 0),
            columnInfo(mode, "param", "integer", JDBCType.INTEGER, 11)));
    expected.put("rows", singletonList(Arrays.asList("foo", 10)));
    assertResponse(expected,
            runSql(mode, new StringEntity("{\"query\":\"SELECT test, ? param FROM test WHERE test = ?\", "
                    + "\"params\":[{\"type\": \"integer\", \"value\": 10}, {\"type\": \"keyword\", \"value\": \"foo\"}]}",
                    ContentType.APPLICATION_JSON)));
}

From source file:org.tec.webapp.jdbc.entity.support.Parameter.java

/**
 * INTEGER type ctor add an integer parameter
 * @param data the integer data//from  w ww .j  a va  2s .c o  m
 */
public Parameter(Integer data) {
    this.mData = data;
    this.mType = JDBCType.INTEGER;
}

From source file:org.tec.webapp.jdbc.entity.support.Parameter.java

/**
 * Long type ctor add an integer parameter
 * @param data the long data//from w  w  w  .  j av a  2 s .c o m
 */
public Parameter(Long data) {
    this.mData = data;
    // TODO verify right type
    this.mType = JDBCType.INTEGER;
}