use of com.varsql.core.connection.beans.ConnectionInfo in project varsql by varsqlinfo.
the class ConnectionInfoComponent method getConnectionInfo.
@Override
public ConnectionInfo getConnectionInfo(String connid) throws EncryptDecryptException {
logger.debug("create connection info : {}", connid);
ConnectionInfo connInfo = new ConnectionInfo();
ConnectionInfoDTO dto = dbConnectionEntityRepository.findByConnInfo(connid);
connInfo.setConnid(dto.getConnection().getVconnid());
connInfo.setAliasName(dto.getConnection().getVname());
connInfo.setType(dto.getProvider().getDbType().toLowerCase());
connInfo.setUsername(dto.getConnection().getVid());
String pw = dto.getConnection().getVpw();
connInfo.setPassword("");
if (!StringUtils.isBlank(pw)) {
connInfo.setPassword(DBPasswordCryptionFactory.getInstance().decrypt(pw));
}
connInfo.setPoolOptions(dto.getConnection().getVpoolopt());
connInfo.setConnectionOptions(dto.getConnection().getVconnopt());
connInfo.setMaxActive(NumberUtils.toInt(dto.getConnection().getMaxActive() + "", 10));
connInfo.setMinIdle(NumberUtils.toInt(dto.getConnection().getMinIdle() + "", 3));
connInfo.setConnectionTimeOut(NumberUtils.toInt(dto.getConnection().getTimeout() + "", 18000));
connInfo.setExportCount(NumberUtils.toInt(dto.getConnection().getExportcount() + "", 1000));
connInfo.setTestWhileIdle("Y".equals(dto.getConnection().getTestWhileIdle()));
String defaultDriverValidationQuery = ValidationProperty.getInstance().validationQuery(connInfo.getType());
String urlDirectYn = dto.getConnection().getUrlDirectYn();
if ("Y".equals(urlDirectYn)) {
connInfo.setUrl(dto.getConnection().getVurl());
} else {
connInfo.setUrl(VarsqlJdbcUtil.getJdbcUrl(dto.getDriver().getUrlFormat(), JdbcURLFormatParam.builder().serverIp(dto.getConnection().getVserverip()).port(Integer.parseInt(dto.getConnection().getVport() + "")).databaseName(dto.getConnection().getVdatabasename()).build()));
}
defaultDriverValidationQuery = StringUtils.isBlank(dto.getDriver().getValidationQuery()) ? defaultDriverValidationQuery : dto.getDriver().getValidationQuery();
String validation_query = dto.getProvider().getValidationQuery();
validation_query = StringUtils.isBlank(validation_query) ? defaultDriverValidationQuery : validation_query;
connInfo.setValidationQuery(validation_query);
List<FileInfo> driverFileInfos;
if (PathType.PATH.equals(PathType.getPathType(dto.getProvider().getPathType()))) {
try {
driverFileInfos = FileServiceUtils.getFileInfos(dto.getProvider().getDriverPath().split(";"));
} catch (IOException e) {
logger.error("driver load fail : " + dto.getProvider().getDriverPath());
driverFileInfos = null;
}
} else {
driverFileInfos = FileServiceUtils.getFileInfos(dbTypeDriverFileEntityRepository.findByFileContId(dto.getProvider().getDriverProviderId()));
}
JDBCDriverInfo jdbcDriverInfo = new JDBCDriverInfo(dto.getDriver().getDriverId(), dto.getDriver().getDbdriver());
jdbcDriverInfo.setDriverFiles(driverFileInfos);
connInfo.setJdbcDriverInfo(jdbcDriverInfo);
return connInfo;
}
use of com.varsql.core.connection.beans.ConnectionInfo in project varsql by varsqlinfo.
the class ConnectionFactory method getConnection.
@Override
public synchronized Connection getConnection() throws ConnectionFactoryException {
if (initFlag == false) {
ConnectionInfo baseConInfo = new ConnectionInfo();
try {
BeanUtils.copyProperties(baseConInfo, Configuration.getInstance().getVarsqlDB());
baseConInfo.setMaxActive(10);
baseConInfo.setMinIdle(2);
createPool(baseConInfo);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.error("vsql connection pool error : {} ", e.getMessage(), e);
} catch (SQLException e) {
logger.error("vsql connection pool error : {} ", e.getMessage(), e);
}
initFlag = true;
}
return getConnection("varsql");
}
use of com.varsql.core.connection.beans.ConnectionInfo in project varsql by varsqlinfo.
the class JPAConfigurer method initialize.
@PostConstruct
public void initialize() {
ConnectionInfo ci = Configuration.getInstance().getVarsqlDB();
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(ci.getJdbcDriverInfo().getDriverClass());
dataSource.setUrl(ci.getUrl());
dataSource.setUsername(ci.getUsername());
dataSource.setPassword(ci.getPassword());
logger.debug("=================datasourceconfig info====================");
logger.debug(" driver : {}", ci.getJdbcDriverInfo().getDriverClass());
logger.debug(" url : {}", ci.getUrl());
logger.debug(" username", ci.getUsername());
logger.debug("=================datasourceconfig info====================");
mainDataSource = dataSource;
}
use of com.varsql.core.connection.beans.ConnectionInfo in project varsql by varsqlinfo.
the class ConnectionFactory method createConnectionInfo.
/**
* @Method Name : createConnectionInfo
* @Method 설명 : connection info 생성.
* @작성일 : 2018. 2. 13.
* @작성자 : ytkim
* @변경이력 :
* @param connid
* @return
* @throws Exception
*/
private synchronized ConnectionInfo createConnectionInfo(String connid) throws ConnectionFactoryException {
try {
ConnectionInfo connInfo = connectionInfoDao.getConnectionInfo(connid);
getPoolBean().createDataSource(connInfo);
this.connectionConfig.put(connid, connInfo);
return connInfo;
} catch (Exception e) {
this.logger.error("empty connection info", e);
throw new ConnectionFactoryException("empty connection info : [" + connid + "]", e);
}
}
use of com.varsql.core.connection.beans.ConnectionInfo in project varsql by varsqlinfo.
the class BaseExecutorTest method testUpdate.
// @Test
// @Ignore
void testUpdate() {
ConnectionInfo connInfo = getBaseConnection();
try {
DatabaseInfo di = getDatabaseInfo(connInfo);
SqlStatementInfo sqi = new SqlStatementInfo();
sqi.setSchema("PUBLIC");
sqi.setConuid(connInfo.getConnid(), TEST_CON_UID, di);
SQLExecutor baseExecutor = new SqlUpdateExecutor();
sqi.setSqlParam("{}");
String insertQuery = getResourceContent("/db/importdata/insertdata.sql");
sqi.setSql(insertQuery);
SQLExecuteResult ser = baseExecutor.execute(sqi, new AbstractSQLExecutorHandler() {
@Override
public boolean handle(SQLHandlerParameter handleParam) {
return true;
}
});
System.out.println("testUpdate ser.getTotalCount(): " + ser.getTotalCount());
System.out.println("testUpdate ser.getResult(): " + ser.getResult());
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations