List of utility methods to do SQL Type
InputStream | convertToStream(final Object o) convert To Stream if (o instanceof byte[]) { return new ByteArrayInputStream((byte[]) o); if (o instanceof Blob) { final Blob b = (Blob) o; try { return b.getBinaryStream(); } catch (SQLException e) { ... |
String | convertToString(int datatype) Converts the data type id to data type string switch (datatype) { case Types.ARRAY: return "ARRAY"; case Types.BIGINT: return "BIGINT"; case Types.BINARY: return "BINARY"; case Types.BIT: ... |
int | convertType(final int type) Types.ARRAY is not supported switch (type) { case Types.BIT: case Types.BOOLEAN: return PG_TYPE_BOOL; case Types.VARCHAR: return PG_TYPE_VARCHAR; case Types.CHAR: return PG_TYPE_BPCHAR; ... |
int | convertType(final int type, final String typeName) Types.ARRAY is not supported switch (type) { case Types.BIT: case Types.BOOLEAN: return PG_TYPE_BOOL; case Types.VARCHAR: return PG_TYPE_VARCHAR; case Types.CHAR: return PG_TYPE_BPCHAR; ... |
void | createAllTypesTable(Connection conn) Following several methods are setup and tearDown methods for ALL_TYPES table. try (Statement statement = conn.createStatement()) { statement.execute( "create table ALL_TYPES (SMALL_INT_COL smallint, INT_COL integer, BIG_INT_COL bigint, REAL_COL real, DOUBLE_COL double," + "DECIMAL_COL decimal(20,10), CHAR_COL char(4), VARCHAR_COL varchar(8), BLOB_COL blob(16), CLOB_COL clob(16), DATE_COL date," + "TIME_COL time, TIMESTAMP_COL timestamp, BOOLEAN_COL boolean)"); |
int[] | createArrTypSql(String[] arr) create Arr Typ Sql int[] types = new int[arr.length]; for (int i = 0; i < arr.length; i++) { types[i] = Types.VARCHAR; types[arr.length - 1] = Types.CHAR; return types; |
String | createSignature(Method m) Extracts parameters from a given method object and formats the string names of the methods parameters into a compatible signature StringBuffer sb = new StringBuffer(); Class[] params = m.getParameterTypes(); sb.append("("); for (int i = 0; i < params.length; i++) { String str1 = params[i].getName(); if (str1.equals("short")) sb.append("S"); else if (str1.equals("int")) ... |
String | createSqlDataType(@Nonnull final String javaDataType) Create the java.sql.Types type for the given Java datatype. if ("boolean".equals(javaDataType) || "java.lang.Boolean".equals(javaDataType)) { return "java.sql.Types.BOOLEAN"; } else if ("byte".equals(javaDataType) || "java.lang.Byte".equals(javaDataType)) { return "java.sql.Types.TINYINT"; } else if ("short".equals(javaDataType) || "java.lang.Short".equals(javaDataType)) { return "java.sql.Types.SMALLINT"; } else if ("int".equals(javaDataType) || "java.lang.Integer".equals(javaDataType)) { return "java.sql.Types.INTEGER"; ... |
void | createTable2() create Table Connection conn = DriverManager.getConnection(protocol + dbName + ";create=true"); Statement st = conn.createStatement(); String sql = "create table whore2(id bigint primary key,obj blob)"; st.execute(sql); st.close(); conn.close(); |
void | createTestData() create Test Data java.sql.Connection jdbcConn = openJDBCConnection(); java.sql.Statement jdbcStmt = jdbcConn.createStatement(); String sql = "drop table " + TABLE_NAME; try { jdbcStmt.execute(sql); } catch (Exception e) { sql = "create table " + TABLE_NAME + "("; ... |