Search in sources :

Example 1 with DataSourceService

use of com.alibaba.nacos.config.server.service.datasource.DataSourceService in project nacos by alibaba.

the class StandaloneDatabaseOperateImpl method init.

@PostConstruct
protected void init() {
    DataSourceService dataSourceService = DynamicDataSource.getInstance().getDataSource();
    jdbcTemplate = dataSourceService.getJdbcTemplate();
    transactionTemplate = dataSourceService.getTransactionTemplate();
    LogUtil.DEFAULT_LOG.info("use StandaloneDatabaseOperateImpl");
}
Also used : DataSourceService(com.alibaba.nacos.config.server.service.datasource.DataSourceService) PostConstruct(javax.annotation.PostConstruct)

Example 2 with DataSourceService

use of com.alibaba.nacos.config.server.service.datasource.DataSourceService in project nacos by alibaba.

the class DerbySnapshotOperation method doDerbyBackup.

private void doDerbyBackup(String backupDirectory) throws Exception {
    DataSourceService sourceService = DynamicDataSource.getInstance().getDataSource();
    DataSource dataSource = sourceService.getJdbcTemplate().getDataSource();
    try (Connection holder = Objects.requireNonNull(dataSource, "dataSource").getConnection()) {
        CallableStatement cs = holder.prepareCall(backupSql);
        cs.setString(1, backupDirectory);
        cs.execute();
    }
}
Also used : CallableStatement(java.sql.CallableStatement) Connection(java.sql.Connection) DataSourceService(com.alibaba.nacos.config.server.service.datasource.DataSourceService) DataSource(javax.sql.DataSource) DynamicDataSource(com.alibaba.nacos.config.server.service.datasource.DynamicDataSource)

Example 3 with DataSourceService

use of com.alibaba.nacos.config.server.service.datasource.DataSourceService in project nacos by alibaba.

the class DerbySnapshotOperation method doDerbyRestoreFromBackup.

private void doDerbyRestoreFromBackup(Callable<Void> callable) throws Exception {
    DataSourceService sourceService = DynamicDataSource.getInstance().getDataSource();
    LocalDataSourceServiceImpl localDataSourceService = (LocalDataSourceServiceImpl) sourceService;
    localDataSourceService.restoreDerby(restoreDB, callable);
}
Also used : LocalDataSourceServiceImpl(com.alibaba.nacos.config.server.service.datasource.LocalDataSourceServiceImpl) DataSourceService(com.alibaba.nacos.config.server.service.datasource.DataSourceService)

Aggregations

DataSourceService (com.alibaba.nacos.config.server.service.datasource.DataSourceService)3 DynamicDataSource (com.alibaba.nacos.config.server.service.datasource.DynamicDataSource)1 LocalDataSourceServiceImpl (com.alibaba.nacos.config.server.service.datasource.LocalDataSourceServiceImpl)1 CallableStatement (java.sql.CallableStatement)1 Connection (java.sql.Connection)1 PostConstruct (javax.annotation.PostConstruct)1 DataSource (javax.sql.DataSource)1