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:edumsg.core.commands.list.GetListFeedsCommand.java
@Override public void execute() { ResultSet set = null;//from w w w . j a va 2 s . c o m try { dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_list_feeds(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setInt(2, Integer.parseInt(map.get("list_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); String retweeter = set.getString(8); Integer creator_id = set.getInt(9); Integer retweeter_id = set.getInt(10); Tweet t = new Tweet(); t.setId(id); t.setTweetText(tweet); t.setImageUrl(image_url); t.setCreatedAt(created_at); User creator = new User(); creator.setId(creator_id); creator.setName(creator_name); creator.setAvatarUrl(creator_avatar); creator.setUsername(creator_username); t.setCreator(creator); if (!creator_name.equals(retweeter)) { User r = new User(); r.setId(retweeter_id); r.setName(retweeter); t.setRetweeter(r); } tweets.addPOJO(t); } root.set("list_feeds", tweets); try { CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER); JSONObject cacheEntry = new JSONObject(mapper.writeValueAsString(root)); cacheEntry.put("cacheStatus", "valid"); ListCache.listCache.set("get_list_feeds:" + map.getOrDefault("session_id", ""), cacheEntry.toString()); } 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); } }
From source file:edumsg.core.commands.dm.GetConversationCommand.java
@Override public void execute() { try {//w w w . j a v a2s.c om dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_conversation(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setInt(2, Integer.parseInt(map.get("conv_id"))); proc.execute(); set = (ResultSet) proc.getObject(1); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); Conversation conv = new Conversation(); ArrayList<DirectMessage> dms = new ArrayList<>(); while (set.next()) { int sender_id = set.getInt(1); String sender_name = set.getString(2); String sender_username = set.getString(3); int reciever_id = set.getInt(4); String reciever_name = set.getString(5); String receiver_username = set.getString(6); String dm_text = set.getString(7); String image_url = set.getString(8); Timestamp created_at = set.getTimestamp(9); String sender_avatar = set.getString(10); String receiver_avatar = set.getString(11); User sender = new User(); sender.setId(sender_id); sender.setName(sender_name); sender.setAvatarUrl(sender_avatar); sender.setUsername(sender_username); User reciever = new User(); reciever.setId(reciever_id); reciever.setName(reciever_name); reciever.setAvatarUrl(receiver_avatar); reciever.setUsername(receiver_username); DirectMessage dm = new DirectMessage(); dm.setDmText(dm_text); dm.setSender(sender); dm.setReciever(reciever); dm.setCreatedAt(created_at); dm.setImageUrl(image_url); dms.add(dm); } conv.setDms(dms); ValueNode child = nf.pojoNode(conv); root.set("conv", child); try { CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER); JSONObject cacheEntry = new JSONObject(mapper.writeValueAsString(root)); cacheEntry.put("cacheStatus", "valid"); DMCache.dmCache.set("get_conv:" + map.getOrDefault("session_id", ""), cacheEntry.toString()); } 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); } }
From source file:net.sourceforge.squirrel_sql.plugins.postgres.types.PostgreSqlOtherTypeDataTypeComponentFactory.java
@Override public boolean matches(DialectType dialectType, int sqlType, String sqlTypeName) { return new EqualsBuilder().append(getDialectType(), dialectType).append(Types.OTHER, sqlType) .append(this.typeName, sqlTypeName).isEquals(); }
From source file:org.mule.module.db.internal.domain.type.MetadataDbTypeManager.java
@Override public DbType lookup(DbConnection connection, int id, String name) throws UnknownDbTypeException { if (!initialised) { synchronized (lock) { if (!initialised) { initialise(connection);/*from w ww. j av a2 s . com*/ initialised = true; } } } String typeKey = name + id; if (typesById.containsKey(typeKey)) { return typesById.get(typeKey); } else if (id == Types.OTHER) { return UnknownDbType.getInstance(); } else { throw new UnknownDbTypeException(id, name); } }
From source file:edumsg.core.commands.dm.GetConversationsCommand.java
@Override public void execute() { ResultSet set = null;//w w w . j a va2 s . c om try { dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_conversations(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setString(2, map.get("session_id")); proc.execute(); set = (ResultSet) proc.getObject(1); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); ArrayList<Conversation> convs = new ArrayList<>(); while (set.next()) { int conv_id = set.getInt(1); int sender_id = set.getInt(2); String sender_name = set.getString(3); int reciever_id = set.getInt(4); String reciever_name = set.getString(5); String dm_text = set.getString(6); Timestamp created_at = set.getTimestamp(7); String sender_username = set.getString(8); String receiver_username = set.getString(9); String sender_avatar = set.getString(10); String receiver_avatar = set.getString(11); User sender = new User(); sender.setId(sender_id); sender.setName(sender_name); sender.setUsername(sender_username); sender.setAvatarUrl(sender_avatar); User reciever = new User(); reciever.setId(reciever_id); reciever.setName(reciever_name); reciever.setUsername(receiver_username); reciever.setAvatarUrl(receiver_avatar); Conversation conv = new Conversation(); conv.setId(conv_id); DirectMessage dm = new DirectMessage(); dm.setSender(sender); dm.setReciever(reciever); dm.setDmText(dm_text); dm.setCreatedAt(created_at); conv.setLastDM(dm); convs.add(conv); } ValueNode child = nf.pojoNode(convs); root.set("convs", child); try { CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER); JSONObject cacheEntry = new JSONObject(mapper.writeValueAsString(root)); cacheEntry.put("cacheStatus", "valid"); TweetsCache.tweetCache.set("get_convs:" + map.getOrDefault("session_id", ""), cacheEntry.toString()); } 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); } }
From source file:edumsg.core.commands.user.GetUserWithTweetsCommand.java
@Override public void execute() { try {//from w w w. j av a 2 s. c o m details = null; //Cache.returnUser(map.get("username")); User user = new User(); dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_user_with_tweets(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setString(2, map.get("username")); 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 username = set.getString(2); String email = set.getString(3); String name = set.getString(5); String language = set.getString(6); String country = set.getString(7); String bio = set.getString(8); String website = set.getString(9); Timestamp created_at = set.getTimestamp(10); String avatar_url = set.getString(11); Boolean overlay = set.getBoolean(12); String link_color = set.getString(13); String background_color = set.getString(14); Boolean protected_tweets = set.getBoolean(15); user.setId(id); user.setUsername(username); user.setEmail(email); user.setName(name); user.setLanguage(language); user.setCountry(country); user.setBio(bio); user.setWebsite(website); user.setCreatedAt(created_at); user.setAvatarUrl(avatar_url); user.setOverlay(overlay); user.setLinkColor(link_color); user.setBackgroundColor(background_color); user.setProtectedTweets(protected_tweets); Integer tweet_id = set.getInt(16); String tweet = set.getString(17); Timestamp tweet_created_at = set.getTimestamp(19); String image_url = set.getString(20); Tweet t = new Tweet(); t.setId(tweet_id); t.setTweetText(tweet); t.setImageUrl(image_url); t.setCreatedAt(tweet_created_at); t.setCreator(user); tweets.addPOJO(t); System.out.println(tweet); } ValueNode child = nf.pojoNode(user); root.set("user", child); // root.set("tweets", tweets); set.close(); proc.close(); root.set("tweets", 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); } }
From source file:edumsg.core.commands.tweet.GetTweetCommand.java
@Override public void execute() { try {//from w ww .j a v a 2s.c o m Tweet t = new Tweet(); User creator = new User(); details = null; //Cache.returnTweet(map.get("tweet_id")); if (details == null) { dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_tweet(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setInt(2, Integer.parseInt(map.get("tweet_id"))); proc.execute(); set = (ResultSet) proc.getObject(1); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); if (set.next()) { details = new HashMap<>(); Integer id = set.getInt(1); String tweet = set.getString(2); String image_url = set.getString(5); Timestamp created_at = set.getTimestamp(4); String creator_username = set.getString(6); String creator_name = set.getString(7); String creator_avatar = set.getString(8); int retweets = set.getInt(9); int favorites = set.getInt(10); t.setId(id); t.setTweetText(tweet); t.setImageUrl(image_url); t.setCreatedAt(created_at); t.setRetweets(retweets); t.setFavorites(favorites); creator.setName(creator_name); creator.setAvatarUrl(creator_avatar); creator.setUsername(creator_username); t.setCreator(creator); // details.put("tweet_text",tweet); // details.put("creator_id",Cache.returnUserID(creator_username)); // details.put("creator_at",created_at.toString()); // details.put("image_url",image_url); //Cache.cacheTweet(id+"",details); } set.close(); ValueNode child = nf.pojoNode(t); root.set("tweet", child); 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(); } else { t.setId(Integer.parseInt(details.get("id"))); t.setTweetText(details.get("tweet_text")); t.setImageUrl(details.get("image_url")); t.setCreatedAt(Timestamp.valueOf(details.get("created_at"))); t.setRetweets(Integer.parseInt(details.get("retweets"))); t.setFavorites(Integer.parseInt(details.get("favorites"))); // creator.setName(creator_name); // creator.setAvatarUrl(creator_avatar); // creator.setUsername(creator_username); t.setCreator(creator); } } 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); } }
From source file:org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TypeMapper.java
private static Class mapSQLType(final int t) { switch (t) {/*from w w w. j a v a2 s .c o m*/ case Types.ARRAY: return Object[].class; case Types.BIGINT: return Long.class; case Types.BINARY: return byteArrayClass; case Types.BIT: return Boolean.class; case Types.BLOB: return Blob.class; case Types.BOOLEAN: // Types.BOOLEAN was not part of JDK1.2.2 return Boolean.class; case Types.CHAR: return String.class; case Types.CLOB: return Clob.class; case Types.DATALINK: // Types.DATALINK was not part of JDK 1.2.2 return URL.class; case Types.DATE: return java.sql.Date.class; case Types.DECIMAL: return java.math.BigDecimal.class; case Types.DISTINCT: return Object.class; case Types.DOUBLE: return Double.class; case Types.FLOAT: return Double.class; case Types.INTEGER: return Integer.class; case Types.JAVA_OBJECT: return Object.class; case Types.LONGVARBINARY: return byteArrayClass; case Types.LONGVARCHAR: return String.class; case Types.NCLOB: return NClob.class; case Types.NULL: return Object.class; case Types.NUMERIC: return java.math.BigDecimal.class; case Types.NCHAR: case Types.NVARCHAR: case Types.LONGNVARCHAR: return String.class; case Types.OTHER: return Object.class; case Types.REAL: return Float.class; case Types.REF: return Ref.class; case Types.ROWID: return RowId.class; case Types.SMALLINT: return Short.class; case Types.STRUCT: return Struct.class; case Types.SQLXML: return SQLXML.class; case Types.TIME: return Time.class; case Types.TIMESTAMP: return Timestamp.class; case Types.TINYINT: return Byte.class; case Types.VARBINARY: return byteArrayClass; case Types.VARCHAR: return String.class; default: return Object.class; } }
From source file:edumsg.core.commands.user.GetUserCommand.java
@Override public void execute() { try {//from w w w . ja v a2 s . co m details = null; //Cache.returnUser(map.get("username")); User user = new User(); if (details == null) { dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call get_user(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setInt(2, Integer.parseInt(map.get("user_id"))); proc.execute(); set = (ResultSet) proc.getObject(1); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); if (set.next()) { Integer id = set.getInt(1); String username = set.getString(2); String email = set.getString(3); String name = set.getString(5); String language = set.getString(6); String country = set.getString(7); String bio = set.getString(8); String website = set.getString(9); Timestamp created_at = set.getTimestamp(10); String avatar_url = set.getString(11); Boolean overlay = set.getBoolean(12); String link_color = set.getString(13); String background_color = set.getString(14); Boolean protected_tweets = set.getBoolean(15); user.setId(id); user.setUsername(username); user.setEmail(email); user.setName(name); user.setLanguage(language); user.setCountry(country); user.setBio(bio); user.setWebsite(website); user.setCreatedAt(created_at); user.setAvatarUrl(avatar_url); user.setOverlay(overlay); user.setLinkColor(link_color); user.setBackgroundColor(background_color); user.setProtectedTweets(protected_tweets); } set.close(); proc.close(); } else { user.setId(Integer.parseInt(details.get("id"))); user.setUsername(details.get("username")); user.setEmail(details.get("email")); user.setName(details.get("name")); user.setLanguage(details.get("language")); user.setCountry(details.get("country")); user.setBio(details.get("bio")); user.setWebsite(details.get("website")); user.setCreatedAt(Timestamp.valueOf(details.get("created_at"))); user.setAvatarUrl(details.get("avatar_url")); user.setOverlay(Boolean.parseBoolean(details.get("overlay"))); user.setLinkColor(details.get("link_color")); user.setBackgroundColor(details.get("background_color")); user.setProtectedTweets(Boolean.parseBoolean(details.get("protected_tweets"))); } ValueNode child = nf.pojoNode(user); root.set("user", child); 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.MyProfileCommand.java
@Override public void execute() { try {/*from ww w. j a v a2 s . c o m*/ details = null; //Cache.returnUser(map.get("username")); User user = new User(); if (details == null) { dbConn = PostgresConnection.getDataSource().getConnection(); dbConn.setAutoCommit(false); proc = dbConn.prepareCall("{? = call my_profile(?)}"); proc.setPoolable(true); proc.registerOutParameter(1, Types.OTHER); proc.setString(2, map.get("session_id")); proc.execute(); set = (ResultSet) proc.getObject(1); root.put("app", map.get("app")); root.put("method", map.get("method")); root.put("status", "ok"); root.put("code", "200"); if (set.next()) { Integer id = set.getInt(1); String username = set.getString(2); String email = set.getString(3); String name = set.getString(5); String language = set.getString(6); String country = set.getString(7); String bio = set.getString(8); String website = set.getString(9); Timestamp created_at = set.getTimestamp(10); String avatar_url = set.getString(11); Boolean overlay = set.getBoolean(12); String link_color = set.getString(13); String background_color = set.getString(14); Boolean protected_tweets = set.getBoolean(15); user.setId(id); user.setUsername(username); user.setEmail(email); user.setName(name); user.setLanguage(language); user.setCountry(country); user.setBio(bio); user.setWebsite(website); user.setCreatedAt(created_at); user.setAvatarUrl(avatar_url); user.setOverlay(overlay); user.setLinkColor(link_color); user.setBackgroundColor(background_color); user.setProtectedTweets(protected_tweets); } set.close(); proc.close(); } else { user.setId(Integer.parseInt(details.get("id"))); user.setUsername(details.get("username")); user.setEmail(details.get("email")); user.setName(details.get("name")); user.setLanguage(details.get("language")); user.setCountry(details.get("country")); user.setBio(details.get("bio")); user.setWebsite(details.get("website")); user.setCreatedAt(Timestamp.valueOf(details.get("created_at"))); user.setAvatarUrl(details.get("avatar_url")); user.setOverlay(Boolean.parseBoolean(details.get("overlay"))); user.setLinkColor(details.get("link_color")); user.setBackgroundColor(details.get("background_color")); user.setProtectedTweets(Boolean.parseBoolean(details.get("protected_tweets"))); } ValueNode child = nf.pojoNode(user); root.set("user", child); 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); } }