Search in sources :

Example 6 with FileInfo

use of com.varsql.core.common.beans.FileInfo 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

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