Search in sources :

Example 6 with BatchContainerServiceException

use of com.ibm.jbatch.container.exception.BatchContainerServiceException in project Payara by payara.

the class PostgresPersistenceManager method init.

@Override
public void init(IBatchConfig batchConfig) throws BatchContainerServiceException {
    logger.config("Entering CLASSNAME.init(), batchConfig =" + batchConfig);
    this.batchConfig = batchConfig;
    schema = batchConfig.getDatabaseConfigurationBean().getSchema();
    jndiName = batchConfig.getDatabaseConfigurationBean().getJndiName();
    try {
        Context ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(jndiName);
    } catch (NamingException e) {
        logger.severe("Lookup failed for JNDI name: " + jndiName + ".  One cause of this could be that the batch runtime is incorrectly configured to EE mode when it should be in SE mode.");
        throw new BatchContainerServiceException(e);
    }
    // Load the table names and queries shared between different database
    // types
    tableNames = getSharedTableMap(batchConfig);
    try {
        queryStrings = getSharedQueryMap(batchConfig);
    } catch (SQLException e1) {
        // TODO Auto-generated catch block
        throw new BatchContainerServiceException(e1);
    }
    // put the create table strings into a hashmap
    // createTableStrings = setCreateTableMap(batchConfig);
    createPostgresStrings = setCreatePostgresStringsMap(batchConfig);
    logger.config("JNDI name = " + jndiName);
    if (jndiName == null || jndiName.equals("")) {
        throw new BatchContainerServiceException("JNDI name is not defined.");
    }
    try {
        if (!isPostgresSchemaValid()) {
            setDefaultSchema();
        }
        checkPostgresTables();
    } catch (SQLException e) {
        logger.severe(e.getLocalizedMessage());
        throw new BatchContainerServiceException(e);
    }
    logger.config("Exiting CLASSNAME.init()");
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) SQLException(java.sql.SQLException) NamingException(javax.naming.NamingException) BatchContainerServiceException(com.ibm.jbatch.container.exception.BatchContainerServiceException) InitialContext(javax.naming.InitialContext)

Example 7 with BatchContainerServiceException

use of com.ibm.jbatch.container.exception.BatchContainerServiceException in project Payara by payara.

the class SQLServerPersistenceManager method init.

@Override
public void init(IBatchConfig batchConfig) throws BatchContainerServiceException {
    LOGGER.entering(CLASSNAME, "init", batchConfig);
    schema = batchConfig.getDatabaseConfigurationBean().getSchema();
    jndiName = batchConfig.getDatabaseConfigurationBean().getJndiName();
    if (null == jndiName || jndiName.isEmpty()) {
        throw new BatchContainerServiceException("JNDI name is not defined.");
    }
    Context ctx;
    try {
        ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(jndiName);
    } catch (NamingException e) {
        LOGGER.log(Level.SEVERE, "Lookup failed for JNDI name: {0}. " + "One cause of this could be that the batch runtime " + "is incorrectly configured to EE mode when it " + "should be in SE mode.", jndiName);
        throw new BatchContainerServiceException(e);
    }
    // Load the table names and queries shared between different database types
    tableNames = getSharedTableMap(batchConfig);
    schemaTableNames = getSharedSchemaTableMap(batchConfig);
    try {
        queryStrings = getSQLServerSharedQueryMap(batchConfig);
    } catch (SQLException e1) {
        throw new BatchContainerServiceException(e1);
    }
    SQLServerCreateStrings = setCreateSQLServerStringsMap(batchConfig);
    LOGGER.log(Level.CONFIG, "JNDI name = {0}", jndiName);
    try {
        if (!isSQLServerSchemaValid()) {
            setDefaultSchema();
        }
        checkSQLServerTables();
    } catch (SQLException e) {
        LOGGER.severe(e.getLocalizedMessage());
        throw new BatchContainerServiceException(e);
    }
    LOGGER.exiting(CLASSNAME, "init");
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) SQLException(java.sql.SQLException) BatchContainerServiceException(com.ibm.jbatch.container.exception.BatchContainerServiceException) NamingException(javax.naming.NamingException) InitialContext(javax.naming.InitialContext)

Aggregations

BatchContainerServiceException (com.ibm.jbatch.container.exception.BatchContainerServiceException)7 SQLException (java.sql.SQLException)7 InitialContext (javax.naming.InitialContext)7 NamingException (javax.naming.NamingException)7 Context (javax.naming.Context)5 RequestTracingService (fish.payara.nucleus.requesttracing.RequestTracingService)2