Example usage for java.sql Types OTHER

List of usage examples for java.sql Types OTHER

Introduction

In this page you can find the example usage for java.sql Types OTHER.

Prototype

int OTHER

To view the source code for java.sql Types OTHER.

Click Source Link

Document

The constant in the Java programming language that indicates that the SQL type is database-specific and gets mapped to a Java object that can be accessed via the methods getObject and setObject.

Usage

From source file:net.sourceforge.squirrel_sql.plugins.postgres.types.PostgreSqlUUIDTypeDataTypeComponentFactory.java

@Override
public boolean matches(DialectType dialectType, int sqlType, String sqlTypeName) {
    return new EqualsBuilder().append(getDialectType(), dialectType).append(Types.OTHER, sqlType)
            .append("uuid", sqlTypeName).isEquals();
}

From source file:edumsg.core.commands.user.FollowingCommand.java

@Override
public void execute() {

    try {//from   ww w  .jav  a 2  s .c o  m
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_following(?)}");
        proc.setPoolable(true);
        proc.registerOutParameter(1, Types.OTHER);
        proc.setString(2, map.get("session_id"));
        proc.execute();

        set = (ResultSet) proc.getObject(1);

        ArrayNode usersArray = 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()) {
            String username = set.getString(1);
            String name = set.getString(2);
            String avatar_url = set.getString(3);

            User user = new User();
            user.setUsername(username);
            user.setName(name);
            user.setAvatarUrl(avatar_url);

            usersArray.addPOJO(user);
        }

        set.close();
        proc.close();

        root.set("following", usersArray);
        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.GetListMembershipsCommand.java

@Override
public void execute() {

    try {/*  w  w w  .j  ava 2  s.c  o  m*/
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_list_memberships(?)}");
        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("memberships", 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.FollowersCommand.java

@Override
public void execute() {

    try {//  w w w  .j  a v  a  2 s.com
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_followers(?)}");
        proc.setPoolable(true);
        proc.registerOutParameter(1, Types.OTHER);
        proc.setString(2, map.get("session_id"));
        proc.execute();

        set = (ResultSet) proc.getObject(1);

        ArrayNode usersArray = 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 name = set.getString(3);
            String avatar_url = set.getString(4);

            User user = new User();
            user.setId(id);
            user.setUsername(username);
            user.setName(name);
            user.setAvatarUrl(avatar_url);

            usersArray.addPOJO(user);
        }

        set.close();
        proc.close();

        root.set("followers", usersArray);
        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.UnconfirmedFollowersCommand.java

@Override
public void execute() {

    try {/*w  ww. j a  v a2s.c o m*/
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_unconfirmed_followers(?)}");
        proc.setPoolable(true);
        proc.registerOutParameter(1, Types.OTHER);
        proc.setString(2, map.get("session_id"));
        proc.execute();

        set = (ResultSet) proc.getObject(1);

        ArrayNode usersArray = 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()) {
            String username = set.getString(1);
            String name = set.getString(2);
            String avatar_url = set.getString(3);

            User user = new User();
            user.setUsername(username);
            user.setName(name);
            user.setAvatarUrl(avatar_url);

            usersArray.addPOJO(user);
        }

        set.close();
        proc.close();

        root.set("followers", usersArray);
        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.GetListMembersCommand.java

@Override
public void execute() {

    ResultSet set = null;// w w  w .  java2 s.  c  om
    try {
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_list_members(?)}");
        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 usersArray = 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()) {
            String username = set.getString(2);
            String name = set.getString(1);
            String avatar_url = set.getString(3);

            User user = new User();
            user.setUsername(username);
            user.setName(name);
            user.setAvatarUrl(avatar_url);

            usersArray.addPOJO(user);
        }
        set.close();

        root.set("members", usersArray);
        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.GetUserTweetsCommand.java

@Override
public void execute() {

    try {//from   w  w w.j ava  2 s. c o  m
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_tweets(?)}");
        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);
            Integer creator_id = set.getInt(5);
            String creator_name = set.getString(6);
            String creator_username = set.getString(7);
            String creator_avatar = set.getString(8);

            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);

            tweets.addPOJO(t);
        }

        //            set.close();
        //            proc.close();
        root.set("tweets", 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");
            UserCache.userCache.set("user_tweets:" + map.get("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);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        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.GetListSubscribersCommand.java

@Override
public void execute() {

    ResultSet set = null;//w w w  .j a v a2  s  .c o  m
    try {
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_list_subscribers(?)}");
        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 usersArray = 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()) {
            String username = set.getString(2);
            String name = set.getString(1);
            String avatar_url = set.getString(3);

            User user = new User();
            user.setUsername(username);
            user.setName(name);
            user.setAvatarUrl(avatar_url);

            usersArray.addPOJO(user);
        }

        root.set("subscribers", usersArray);
        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);
    }
}

From source file:edumsg.core.commands.user.GetTimelineCommand.java

@Override
public void execute() {

    try {/*from   w  w  w . j  a  va  2 s  .com*/
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_feeds(?)}");
        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);
            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_id.equals(retweeter_id)) {
                User r = new User();
                r.setId(retweeter_id);
                r.setName(retweeter);
                t.setRetweeter(r);
            }

            tweets.addPOJO(t);
        }
        set.close();
        proc.close();
        root.set("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");
            UserCache.userCache.set("timeline:" + map.get("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);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        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.GetUsersCommand.java

@Override
public void execute() {

    try {/*  ww w .  j  a v  a2 s.  com*/
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(false);
        proc = dbConn.prepareCall("{? = call get_users(?)}");
        proc.setPoolable(true);
        proc.registerOutParameter(1, Types.OTHER);
        proc.setString(2, map.get("user_substring"));
        proc.execute();

        set = (ResultSet) proc.getObject(1);

        ArrayNode usersArray = 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 name = set.getString(3);
            String avatar_url = set.getString(4);

            User user = new User();
            user.setId(id);
            user.setUsername(username);
            user.setName(name);
            user.setAvatarUrl(avatar_url);

            usersArray.addPOJO(user);
        }
        set.close();
        proc.close();
        root.set("users", usersArray);
        try {
            CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"),
                    LOGGER);
            JSONObject cacheEntry = new JSONObject();
            cacheEntry.put("cacheStatus", "valid");
            cacheEntry.put("response", new JSONObject(mapper.writeValueAsString(root)));
            EduMsgRedis.redisCache.set("get_users", 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);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        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);
    }
}