本文整理汇总了Java中org.wso2.carbon.user.core.util.DatabaseUtil类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseUtil类的具体用法?Java DatabaseUtil怎么用?Java DatabaseUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseUtil类属于org.wso2.carbon.user.core.util包,在下文中一共展示了DatabaseUtil类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDBConnection
import org.wso2.carbon.user.core.util.DatabaseUtil; //导入依赖的package包/类
private Connection getDBConnection(RealmConfiguration realmConfiguration) throws SQLException, UserStoreException {
Connection dbConnection = null;
DataSource dataSource = DatabaseUtil.createUserStoreDataSource(realmConfiguration);
if (dataSource != null) {
dbConnection = DatabaseUtil.getDBConnection(dataSource);
}
//if primary user store, DB connection can be same as realm data source.
if (dbConnection == null && realmConfiguration.isPrimary()) {
dbConnection = IdentityDatabaseUtil.getUserDBConnection();
} else if (dbConnection == null) {
throw new UserStoreException("Could not create a database connection to " +
realmConfiguration.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME));
} else {
// db connection is present
}
dbConnection.setAutoCommit(false);
dbConnection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
return dbConnection;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: initDatasource
import org.wso2.carbon.user.core.util.DatabaseUtil; //导入依赖的package包/类
private void initDatasource() {
try {
dataSource = DatabaseUtil.getRealmDataSource(CarbonContext.getThreadLocalCarbonContext().getUserRealm().
getRealmConfiguration());
} catch (UserStoreException e) {
log.error("Error while retrieving user management data source", e);
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: initUMDataSource
import org.wso2.carbon.user.core.util.DatabaseUtil; //导入依赖的package包/类
/**
* This method initializes and execute the um migration scripts.
* @throws Exception
*/
private void initUMDataSource() throws SQLException, IOException {
umDataSource = DatabaseUtil.getRealmDataSource(ServiceHolder.getRealmService().getBootstrapRealmConfiguration());
MigrationDatabaseCreator migrationDatabaseCreator = new MigrationDatabaseCreator(dataSource, umDataSource);
try {
migrationDatabaseCreator.executeUmMigrationScript();
} catch (IOException e) {
throw new IOException("Error while reading um migration script. ",e);
}
}
示例10: databaseMigration
import org.wso2.carbon.user.core.util.DatabaseUtil; //导入依赖的package包/类
@Override
public void databaseMigration() throws EsMigrationException {
try {
umDataSource = DatabaseUtil.getRealmDataSource(ServiceHolder.getRealmService().getBootstrapRealmConfiguration());
MigrationDatabaseCreator migrationDatabaseCreator = new MigrationDatabaseCreator(dataSource, umDataSource);
migrationDatabaseCreator.executeUserPermissionFixScript();
log.info("Database migration completed successfully.");
} catch (Exception e) {
String msg = "Error occurred while executing the database migration.";
log.error(msg, e);
throw new EsMigrationException(msg, e);
}
}
示例11: CassandraUserStoreManager
import org.wso2.carbon.user.core.util.DatabaseUtil; //导入依赖的package包/类
public CassandraUserStoreManager(RealmConfiguration realmConfig, Map<String, Object> properties,
ClaimManager claimManager, ProfileConfigurationManager profileManager, UserRealm realm, Integer tenantId)
throws UserStoreException {
this(realmConfig, tenantId);
if (log.isDebugEnabled()) {
log.debug("Started " + System.currentTimeMillis());
}
this.claimManager = claimManager;
this.userRealm = realm;
dataSource = (DataSource) properties.get(UserCoreConstants.DATA_SOURCE);
if (dataSource == null) {
dataSource = DatabaseUtil.getRealmDataSource(realmConfig);
}
if (dataSource == null) {
throw new UserStoreException("User Management Data Source is null");
}
doInitialSetup();
this.persistDomain();
if (realmConfig.isPrimary()) {
addInitialAdminData(Boolean.parseBoolean(realmConfig.getAddAdmin()), !isInitSetupDone());
}
properties.put(UserCoreConstants.DATA_SOURCE, dataSource);
if (log.isDebugEnabled()) {
log.debug("The jdbcDataSource being used by JDBCUserStoreManager :: " + dataSource.hashCode());
}
if (log.isDebugEnabled()) {
log.debug("Ended " + System.currentTimeMillis());
}
domain = realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
/*
* Initialize user roles cache as implemented in AbstractUserStoreManager
*/
initUserRolesCache();
}