当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseUtil.closeAllConnections方法代码示例

本文整理汇总了Java中org.wso2.carbon.user.core.util.DatabaseUtil.closeAllConnections方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseUtil.closeAllConnections方法的具体用法?Java DatabaseUtil.closeAllConnections怎么用?Java DatabaseUtil.closeAllConnections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.user.core.util.DatabaseUtil的用法示例。


在下文中一共展示了DatabaseUtil.closeAllConnections方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProperty

import org.wso2.carbon.user.core.util.DatabaseUtil; //导入方法依赖的package包/类
public String getProperty(String name) throws SQLException {
    String value = null;
    PreparedStatement stmt = null;
    Connection dbConnection = null;
    ResultSet rs = null;
    try {
        dbConnection = dataSource.getConnection();
        stmt = dbConnection.prepareStatement(GET_PROPERTY);
        stmt.setString(1, name);
        stmt.executeQuery();
        rs = stmt.executeQuery();
        if (rs.next()) {
            value = rs.getString(1);
        }
    } finally {
        DatabaseUtil.closeAllConnections(dbConnection, rs, stmt);
    }
    return value;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:UMDatabaseManager.java

示例2: getExternalStoreProperties

import org.wso2.carbon.user.core.util.DatabaseUtil; //导入方法依赖的package包/类
public Map<String, String> getExternalStoreProperties() throws SQLException {
    Connection dbConnection = null;
    Map<String, String> map = new HashMap<String, String>();
    ResultSet rs = null;
    PreparedStatement stmt = null;

    try {
        dbConnection = dataSource.getConnection();
        stmt = dbConnection.prepareStatement(GET_PROPERTIES);
        rs = stmt.executeQuery();
        while (rs.next()) {
            String name = rs.getString(1);
            String value = rs.getString(2);
            map.put(name, value);
        }
    } finally {
        DatabaseUtil.closeAllConnections(dbConnection, rs, stmt);
    }
    return map;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:UMDatabaseManager.java

示例3: setProperty

import org.wso2.carbon.user.core.util.DatabaseUtil; //导入方法依赖的package包/类
public void setProperty(String name, String value) throws SQLException {
    Connection dbConnection = null;
    PreparedStatement stmt = null;
    try {
        dataSource.getConnection();
        dbConnection = dataSource.getConnection();
        dbConnection.setAutoCommit(false);
        stmt = dbConnection.prepareStatement(SET_PROPERTY);
        stmt.setString(1, name);
        stmt.setString(2, value);
        stmt.executeUpdate();
        stmt.executeUpdate();
    } finally {
        DatabaseUtil.closeAllConnections(dbConnection, stmt);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:17,代码来源:UMDatabaseManager.java

示例4: updateProvisioningEntityName

import org.wso2.carbon.user.core.util.DatabaseUtil; //导入方法依赖的package包/类
/**
 * Applicable for only group name update
 *
 * @param provisioningEntity
 * @throws IdentityApplicationManagementException
 */
public void updateProvisioningEntityName(ProvisioningEntity provisioningEntity) throws
                                                                                IdentityApplicationManagementException {

    Connection dbConnection = null;
    String provisioningEntityName = null;
    String entityLocalID = null;
    PreparedStatement prepStmt = null;
    try {
        dbConnection = JDBCPersistenceManager.getInstance().getDBConnection();

        String sqlStmt = IdentityProvisioningConstants.SQLQueries.UPDATE_PROVISIONED_ENTITY_NAME_SQL;
        prepStmt = dbConnection.prepareStatement(sqlStmt);

        provisioningEntityName = ProvisioningUtil.getAttributeValue(provisioningEntity,
                                                                    IdentityProvisioningConstants.NEW_GROUP_NAME_CLAIM_URI);
        entityLocalID = ProvisioningUtil.getAttributeValue(provisioningEntity,
                                                           IdentityProvisioningConstants.ID_CLAIM_URI);

        prepStmt.setString(1, provisioningEntityName);
        prepStmt.setString(2, entityLocalID);

        prepStmt.execute();
        dbConnection.commit();
    } catch (SQLException e) {
        IdentityApplicationManagementUtil.rollBack(dbConnection);
        String msg = "Error occurred while Updating Provisioning entity name to " + provisioningEntityName +
                     " for Entity Local Id :" + entityLocalID;
        throw new IdentityApplicationManagementException(msg, e);
    } finally {
        DatabaseUtil.closeAllConnections(dbConnection, prepStmt);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:39,代码来源:ProvisioningManagementDAO.java

示例5: deleteAllProperties

import org.wso2.carbon.user.core.util.DatabaseUtil; //导入方法依赖的package包/类
public void deleteAllProperties() throws SQLException {
    Connection dbConnection = null;
    PreparedStatement stmt = null;

    try {
        dbConnection = dataSource.getConnection();
        stmt = dbConnection.prepareStatement(DELETE_PROPERTIES);
        stmt.executeUpdate();
    } finally {
        DatabaseUtil.closeAllConnections(dbConnection, stmt);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:13,代码来源:UMDatabaseManager.java

示例6: createManagementTables

import org.wso2.carbon.user.core.util.DatabaseUtil; //导入方法依赖的package包/类
public void createManagementTables() throws SQLException {

        Connection dbConnection = null;
        ResultSet rs = null;
        Statement stmt = null;
        try {

            dbConnection = dataSource.getConnection();
            DatabaseMetaData dbmd = dbConnection.getMetaData();
            rs = dbmd.getTables(null, null, "USER_MGT_PROPERTIES", null);
            stmt =
                    dbConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

            if (!rs.next()) {

                stmt.executeUpdate(CREATE_TABLE);

                dbConnection.commit();
            }

        } finally {

            if (rs != null) {
                rs.close();
            }
            if (stmt != null) {
                stmt.close();
            }
            DatabaseUtil.closeAllConnections(dbConnection);
        }
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:32,代码来源:UMDatabaseManager.java


注:本文中的org.wso2.carbon.user.core.util.DatabaseUtil.closeAllConnections方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。