Search in sources :

Example 6 with JDBCDriverInfo

use of com.varsql.core.connection.beans.JDBCDriverInfo in project varsql by varsqlinfo.

the class DriverProvierMgmtServiceImpl method driverCheck.

public ResponseResult driverCheck(DBTypeDriverProviderRequestDTO dto) throws EncryptDecryptException {
    ResponseResult resultObject = new ResponseResult();
    String driverProviderId = dto.getDriverProviderId();
    DBTypeDriverProviderEntity entity = dbTypeDriverProviderRepository.findByDriverProviderId(driverProviderId);
    if (entity == null) {
        resultObject.setResultCode(RequestResultCode.NOT_FOUND);
        resultObject.setMessage("db jdbc provider not found : " + driverProviderId);
        return resultObject;
    }
    StringBuffer errorMsg = new StringBuffer();
    try {
        List<FileInfo> driverJarFiles;
        if (PathType.PATH.equals(PathType.getPathType(dto.getPathType()))) {
            driverJarFiles = FileServiceUtils.getFileInfos(dto.getDriverPath().split(";"));
        } else {
            driverJarFiles = FileServiceUtils.getFileInfos(dbTypeDriverFileEntityRepository.findByFileContId(entity.getDriverProviderId()));
        }
        JDBCDriverInfo jdbcDriverInfo = new JDBCDriverInfo(dto.getDriverProviderId(), dto.getDriverClass());
        jdbcDriverInfo.setDriverFiles(driverJarFiles);
        if (JdbcDriverLoader.checkDriver(jdbcDriverInfo) != null) {
            resultObject.setResultCode(VarsqlAppCode.SUCCESS);
        } else {
            resultObject.setMessage("driver null");
            resultObject.setResultCode(VarsqlAppCode.ERROR);
        }
        resultObject.setResultCode(VarsqlAppCode.SUCCESS);
    } catch (ClassNotFoundException e) {
        resultObject.setResultCode(VarsqlAppCode.ERROR);
        resultObject.setMessage("class not found : " + dto.getDriverClass() + "\nerror message : " + e.getMessage());
        logger.error(getClass().getName(), e);
    } catch (Exception e) {
        resultObject.setResultCode(VarsqlAppCode.ERROR);
        resultObject.setMessage(e.getMessage() + BlankConstants.NEW_LINE + errorMsg);
        logger.error(getClass().getName(), e);
    }
    return resultObject;
}
Also used : DBTypeDriverProviderEntity(com.varsql.web.model.entity.db.DBTypeDriverProviderEntity) FileInfo(com.varsql.core.common.beans.FileInfo) ResponseResult(com.vartech.common.app.beans.ResponseResult) JDBCDriverInfo(com.varsql.core.connection.beans.JDBCDriverInfo) VarsqlRuntimeException(com.varsql.core.exception.VarsqlRuntimeException) EncryptDecryptException(com.vartech.common.crypto.EncryptDecryptException) IOException(java.io.IOException) BeansException(org.springframework.beans.BeansException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

JDBCDriverInfo (com.varsql.core.connection.beans.JDBCDriverInfo)6 FileInfo (com.varsql.core.common.beans.FileInfo)4 ConnectionInfo (com.varsql.core.connection.beans.ConnectionInfo)3 EncryptDecryptException (com.vartech.common.crypto.EncryptDecryptException)3 IOException (java.io.IOException)3 DBTypeDriverProviderEntity (com.varsql.web.model.entity.db.DBTypeDriverProviderEntity)2 ResponseResult (com.vartech.common.app.beans.ResponseResult)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 BeansException (org.springframework.beans.BeansException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 VarsqlAppCode (com.varsql.core.common.code.VarsqlAppCode)1 ConnectionFactoryException (com.varsql.core.exception.ConnectionFactoryException)1 VarsqlRuntimeException (com.varsql.core.exception.VarsqlRuntimeException)1 DBConnectionEntity (com.varsql.web.model.entity.db.DBConnectionEntity)1 DBTypeDriverEntity (com.varsql.web.model.entity.db.DBTypeDriverEntity)1 Driver (java.sql.Driver)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1