List of usage examples for java.sql Types OTHER
int OTHER
To view the source code for java.sql Types OTHER.
Click Source Link
getObject
and setObject
. From source file:Main.java
public static String getCloverTypeFromJdbcType(int jdbcDataType) { switch (jdbcDataType) { case Types.DATE: case Types.TIME: case Types.TIMESTAMP: return "date"; case Types.ARRAY: case Types.BINARY: case Types.DATALINK: case Types.BLOB: case Types.DISTINCT: case Types.JAVA_OBJECT: case Types.NULL: case Types.OTHER: case Types.REF: case Types.STRUCT: case Types.VARBINARY: case Types.LONGVARBINARY: System.out.println("Outputting cbyte for Type: " + jdbcDataType); return "cbyte"; case Types.BIT: case Types.BOOLEAN: return "boolean"; case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.NUMERIC: case Types.REAL: return "numeric"; case Types.INTEGER: case Types.SMALLINT: return "integer"; case Types.BIGINT: return "long"; case Types.CHAR: case Types.VARCHAR: case Types.CLOB: case Types.LONGVARCHAR: return "string"; }// w ww .ja va2 s .co m System.out.println("Outputting string for unknown Type: " + jdbcDataType); return "string"; }
From source file:org.apache.hadoop.hive.ql.dataImport.HiveTypes.java
public static String toHiveType(int sqlType) { switch (sqlType) { case Types.INTEGER: case Types.SMALLINT: return "INT"; case Types.VARCHAR: case Types.CHAR: case Types.LONGVARCHAR: case Types.NVARCHAR: case Types.NCHAR: case Types.LONGNVARCHAR: case Types.DATE: case Types.TIME: case Types.TIMESTAMP: case Types.CLOB: case Types.OTHER: return "STRING"; case Types.NUMERIC: case Types.DECIMAL: case Types.FLOAT: case Types.DOUBLE: case Types.REAL: return "DOUBLE"; case Types.BIT: case Types.BOOLEAN: return "BOOLEAN"; case Types.TINYINT: return "TINYINT"; case Types.BIGINT: return "BIGINT"; default://from w w w . ja v a 2 s . co m return null; } }
From source file:org.zalando.stups.jpa.example.sp.ExampleSP.java
public ExampleSP(final DataSource dataSource) { LOG.info("inside NextNumberStoredProcedure datasource: {}", dataSource); setDataSource(dataSource);/*from ww w. java 2s . c o m*/ setFunction(true); setSql(STORED_PROCEDURE_NAME); declareParameter(new SqlParameter(IN_PARAMETER_NAME, Types.OTHER)); declareParameter(new SqlOutParameter(OUT_PARAMETER_NAME, Types.VARCHAR)); compile(); }
From source file:at.alladin.rmbt.db.fields.UUIDField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.OTHER); else/* w w w.ja v a 2 s . c o m*/ ps.setObject(idx, value); }
From source file:net.sourceforge.squirrel_sql.plugins.db2.types.DB2XmlTypeDataTypeComponentFactory.java
@Override public boolean matches(DialectType dialectType, int sqlType, String sqlTypeName) { return new EqualsBuilder().append(getDialectType(), dialectType).append(Types.OTHER, sqlType) .append("XML", sqlTypeName).isEquals(); }
From source file:net.sourceforge.squirrel_sql.plugins.postgres.types.PostgreSqlXmlTypeDataTypeComponentFactory.java
@Override public boolean matches(DialectType dialectType, int sqlType, String sqlTypeName) { return new EqualsBuilder().append(getDialectType(), dialectType).append(Types.OTHER, sqlType) .append("xml", sqlTypeName).isEquals(); }
From source file:edumsg.core.commands.user.GetSubscribedListsCommand.java
@Override public void execute() { try {/* w ww .j a va 2s.c o m*/ dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_subscribed_lists(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setString(2, map.get("session_id")); proc.execute(); set = (ResultSet) proc.getObject(1); ArrayNode lists = nf.arrayNode(); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); while (set.next()) { Integer id = set.getInt(1); String name = set.getString(2); String description = set.getString(3); String creator_name = set.getString(4); String creator_username = set.getString(5); String creator_avatar = set.getString(6); List list = new List(); list.setId(id); list.setName(name); list.setDescription(description); User creator = new User(); creator.setName(creator_name); creator.setAvatarUrl(creator_avatar); creator.setUsername(creator_username); list.setCreator(creator); lists.addPOJO(list); } set.close(); proc.close(); root.set("subscribed_lists", lists); try { CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER); } catch (JsonGenerationException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (JsonMappingException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } dbConn.commit(); } catch (PSQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER); LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (SQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER); LOGGER.log(Level.SEVERE, e.getMessage(), e); } finally { PostgresConnection.disconnect(set, proc, dbConn, null); } }
From source file:edumsg.core.commands.user.GetMentionsCommand.java
@Override public void execute() { try {//from w w w .ja va 2s .c om dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_mentions(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setString(2, map.get("session_id")); proc.execute(); set = (ResultSet) proc.getObject(1); ArrayNode mentions = nf.arrayNode(); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); while (set.next()) { Integer id = set.getInt(1); String tweet = set.getString(2); String image_url = set.getString(3); Timestamp created_at = set.getTimestamp(4); String creator_name = set.getString(5); String creator_username = set.getString(6); String creator_avatar = set.getString(7); Tweet t = new Tweet(); t.setId(id); t.setTweetText(tweet); t.setImageUrl(image_url); t.setCreatedAt(created_at); User creator = new User(); creator.setName(creator_name); creator.setAvatarUrl(creator_avatar); creator.setUsername(creator_username); t.setCreator(creator); mentions.addPOJO(t); } set.close(); proc.close(); root.set("mentions", mentions); try { CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER); } catch (JsonGenerationException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (JsonMappingException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } dbConn.commit(); } catch (PSQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER); LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (SQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER); LOGGER.log(Level.SEVERE, e.getMessage(), e); } finally { PostgresConnection.disconnect(set, proc, dbConn, null); } }
From source file:edumsg.core.commands.list.CreateListMembersCommand.java
@Override public void execute() { try {//from w ww . j a v a 2 s .c om dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(true); proc = dbConn.prepareCall("{call create_list_with_members(?,?,?,?,now()::TIMESTAMP ,?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setString(1, map.get("name")); proc.setString(2, map.get("description")); proc.setString(3, map.get("session_id")); proc.setBoolean(4, Boolean.parseBoolean(map.get("private"))); Array array = dbConn.createArrayOf("varchar", map.get("members").split("")); proc.setArray(5, array); proc.execute(); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); try { CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER); } catch (JsonGenerationException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (JsonMappingException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } catch (PSQLException e) { if (e.getMessage().contains("unique constraint")) { if (e.getMessage().contains("(name)")) { CommandsHelp.handleError(map.get("app"), map.get("method"), "List name already exists", map.get("correlation_id"), LOGGER); } } if (e.getMessage().contains("value too long")) { CommandsHelp.handleError(map.get("app"), map.get("method"), "Too long input", map.get("correlation_id"), LOGGER); } CommandsHelp.handleError(map.get("app"), map.get("method"), "List name already exists", map.get("correlation_id"), LOGGER); LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (SQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), "List name already exists", map.get("correlation_id"), LOGGER); LOGGER.log(Level.SEVERE, e.getMessage(), e); } finally { PostgresConnection.disconnect(null, proc, dbConn); } }
From source file:edumsg.core.commands.user.GetFavoritesCommand.java
@Override public void execute() { try {//w w w . j av a 2s .c om dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_user_favorites(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setString(2, map.get("session_id")); proc.execute(); set = (ResultSet) proc.getObject(1); ArrayNode tweets = nf.arrayNode(); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); while (set.next()) { Integer id = set.getInt(1); String tweet = set.getString(2); String image_url = set.getString(3); Timestamp created_at = set.getTimestamp(4); String creator_name = set.getString(5); String creator_username = set.getString(6); String creator_avatar = set.getString(7); Tweet t = new Tweet(); t.setId(id); t.setTweetText(tweet); t.setImageUrl(image_url); t.setCreatedAt(created_at); User creator = new User(); creator.setName(creator_name); creator.setAvatarUrl(creator_avatar); creator.setUsername(creator_username); t.setCreator(creator); tweets.addPOJO(t); } set.close(); proc.close(); root.set("favorites", tweets); try { CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER); } catch (JsonGenerationException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (JsonMappingException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } dbConn.commit(); } catch (PSQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER); LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (SQLException e) { CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER); LOGGER.log(Level.SEVERE, e.getMessage(), e); } finally { PostgresConnection.disconnect(set, proc, dbConn, null); } }