Example usage for com.liferay.portal.kernel.dao.jdbc DataAccess cleanUp

List of usage examples for com.liferay.portal.kernel.dao.jdbc DataAccess cleanUp

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.jdbc DataAccess cleanUp.

Prototype

public static void cleanUp(Statement statement, ResultSet resultSet) 

Source Link

Usage

From source file:com.liferay.counter.service.persistence.CounterFinderImpl.java

License:Open Source License

public void rename(String oldName, String newName) throws SystemException {
    CounterRegister counterRegister = getCounterRegister(oldName);

    synchronized (counterRegister) {
        if (_counterRegisterMap.containsKey(newName)) {
            throw new SystemException("Cannot rename " + oldName + " to " + newName);
        }//from w  w  w. ja  va 2 s  .co m

        Connection connection = null;
        PreparedStatement preparedStatement = null;

        try {
            connection = getConnection();

            preparedStatement = connection.prepareStatement(_SQL_UPDATE_NAME_BY_NAME);

            preparedStatement.setString(1, newName);
            preparedStatement.setString(2, oldName);

            preparedStatement.executeUpdate();
        } catch (ObjectNotFoundException onfe) {
        } catch (Exception e) {
            throw processException(e);
        } finally {
            DataAccess.cleanUp(connection, preparedStatement);
        }

        counterRegister.setName(newName);

        _counterRegisterMap.put(newName, counterRegister);
        _counterRegisterMap.remove(oldName);
    }
}

From source file:com.liferay.microblogs.hook.upgrade.v1_0_1.UpgradeUserNotificationEvent.java

License:Open Source License

protected void updateNotification(long userNotificationEventId, JSONObject jsonObject) throws Exception {

    Connection con = null;/*from   w  ww .j  a  v a 2  s.c  o  m*/
    PreparedStatement ps = null;

    try {
        con = DataAccess.getUpgradeOptimizedConnection();

        ps = con.prepareStatement(
                "update UserNotificationEvent set payload = ? " + "where userNotificationEventId = ?");

        ps.setString(1, jsonObject.toString());
        ps.setLong(2, userNotificationEventId);

        ps.executeUpdate();
    } finally {
        DataAccess.cleanUp(con, ps);
    }
}

From source file:com.liferay.microblogs.hook.upgrade.v1_0_2.UpgradeSocial.java

License:Open Source License

protected void updateSocialActivity(long activityId, JSONObject jsonObject) throws Exception {

    Connection con = null;//from  w  w w.  j  a  v  a  2 s .  co  m
    PreparedStatement ps = null;

    try {
        con = DataAccess.getUpgradeOptimizedConnection();

        ps = con.prepareStatement("update SocialActivity set extraData = ? where activityId = ?");

        ps.setString(1, jsonObject.toString());
        ps.setLong(2, activityId);

        ps.executeUpdate();
    } finally {
        DataAccess.cleanUp(con, ps);
    }
}

From source file:com.liferay.notifications.hook.upgrade.v1_0_0.UpgradeUserNotificationEvent.java

License:Open Source License

protected void updateNotification(long userNotificationEventId, String type, JSONObject jsonObject)
        throws Exception {

    Connection con = null;/*w  w w  .j a v  a2 s.  c  o  m*/
    PreparedStatement ps = null;

    try {
        con = DataAccess.getUpgradeOptimizedConnection();

        ps = con.prepareStatement("update UserNotificationEvent set type_ = ?, payload = ? "
                + "where userNotificationEventId = ?");

        ps.setString(1, type);
        ps.setString(2, jsonObject.toString());
        ps.setLong(3, userNotificationEventId);

        ps.executeUpdate();
    } finally {
        DataAccess.cleanUp(con, ps);
    }
}

From source file:com.liferay.notifications.hook.upgrade.v1_1_0.UpgradeUserNotificationEvent.java

License:Open Source License

protected void addUserNotificationEvent(long companyId, long userId, long userNotificationEventId,
        long timestamp, boolean actionRequired, boolean delivered, boolean archived) throws Exception {

    Connection con = null;//from   ww  w .j a  v  a 2 s . co  m
    PreparedStatement ps = null;

    try {
        con = DataAccess.getUpgradeOptimizedConnection();

        StringBundler sb = new StringBundler(5);

        sb.append("insert into Notifications_UserNotificationEvent (");
        sb.append("notificationEventId, companyId, userId,");
        sb.append("userNotificationEventId, timestamp , delivered,");
        sb.append("actionRequired, archived) values (?, ?, ?, ?, ?, ?");
        sb.append(", ?, ?)");

        ps = con.prepareStatement(sb.toString());

        ps.setLong(1, increment());
        ps.setLong(2, companyId);
        ps.setLong(3, userId);
        ps.setLong(4, userNotificationEventId);
        ps.setLong(5, timestamp);
        ps.setBoolean(6, actionRequired);
        ps.setBoolean(7, delivered);
        ps.setBoolean(8, archived);

        ps.executeUpdate();
    } finally {
        DataAccess.cleanUp(con, ps);
    }
}

From source file:com.liferay.so.activities.hook.upgrade.v1_0_0.UpgradeSocial.java

License:Open Source License

protected void addActivitySet(long activitySetId, long groupId, long companyId, long userId, long createDate,
        long classNameId, long classPK, int type_) throws Exception {

    Connection con = null;//from   w w  w .ja v  a  2s.  c o  m
    PreparedStatement ps = null;

    try {
        con = DataAccess.getUpgradeOptimizedConnection();

        StringBundler sb = new StringBundler(4);

        sb.append("insert into SocialActivitySet (activitySetId, ");
        sb.append("groupId, companyId, userId, createDate, modifiedDate, ");
        sb.append("classNameId, classPK, type_, activityCount) values ");
        sb.append("(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

        ps = con.prepareStatement(sb.toString());

        ps.setLong(1, activitySetId);
        ps.setLong(2, groupId);
        ps.setLong(3, companyId);
        ps.setLong(4, userId);
        ps.setLong(5, createDate);
        ps.setLong(6, createDate);
        ps.setLong(7, classNameId);
        ps.setLong(8, classPK);
        ps.setInt(9, type_);
        ps.setInt(10, 1);

        ps.executeUpdate();
    } catch (Exception e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to add activity set " + activitySetId, e);
        }
    } finally {
        DataAccess.cleanUp(con, ps);
    }
}

From source file:com.liferay.wsrp.hook.upgrade.v1_1_0.UpgradeUuid.java

License:Open Source License

protected void updateLayout(long plid, String typeSettings) throws Exception {

    Connection con = null;//from www . j ava2s . c o m
    PreparedStatement ps = null;

    try {
        con = DataAccess.getConnection();

        ps = con.prepareStatement("update Layout set typeSettings = ? where plid = " + plid);

        ps.setString(1, typeSettings);

        ps.executeUpdate();
    } finally {
        DataAccess.cleanUp(con, ps);
    }
}

From source file:com.liferay.wsrp.hook.upgrade.v1_1_0.UpgradeUuid.java

License:Open Source License

protected void updateResourceAction(String oldPortletId, String newPortletId) throws Exception {

    Connection con = null;//from w w w . j a v  a 2s.  c om
    PreparedStatement ps = null;

    try {
        con = DataAccess.getConnection();

        ps = con.prepareStatement("update ResourceAction set name = ? where name = ? ");

        ps.setString(1, newPortletId);
        ps.setString(2, oldPortletId);

        ps.executeUpdate();
    } finally {
        DataAccess.cleanUp(con, ps);
    }
}

From source file:com.liferay.wsrp.hook.upgrade.v1_1_0.UpgradeUuid.java

License:Open Source License

protected void updateResourcePermission(long resourcePermissionId, String name, String primKey)
        throws Exception {

    Connection con = null;//from  ww  w. j a  v  a 2 s  .c  o m
    PreparedStatement ps = null;

    try {
        con = DataAccess.getConnection();

        ps = con.prepareStatement(
                "update ResourcePermission set name = ?, primKey = ? where " + "resourcePermissionId = ?");

        ps.setString(1, name);
        ps.setString(2, primKey);
        ps.setLong(3, resourcePermissionId);

        ps.executeUpdate();
    } finally {
        DataAccess.cleanUp(con, ps);
    }
}

From source file:it.dontesta.labs.liferay.portal.dao.db.DB2DB.java

License:Open Source License

protected boolean isRequiresReorgTable(Connection con, String tableName) throws SQLException {

    boolean reorgTableRequired = false;

    PreparedStatement ps = null;//from  ww w. j  a  v  a2  s .co m
    ResultSet rs = null;

    try {
        StringBundler sb = new StringBundler(4);

        sb.append("select num_reorg_rec_alters from table(");
        sb.append("sysproc.admin_get_tab_info(current_schema, '");
        sb.append(StringUtil.toUpperCase(tableName));
        sb.append("')) where reorg_pending = 'Y'");

        ps = con.prepareStatement(sb.toString());

        rs = ps.executeQuery();

        if (rs.next()) {
            int numReorgRecAlters = rs.getInt(1);

            if (numReorgRecAlters >= 1) {
                reorgTableRequired = true;
            }
        }
    } finally {
        DataAccess.cleanUp(ps, rs);
    }

    return reorgTableRequired;
}