All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.akquinet.jbosscc.guttenbase.connector.impl.DataSourceConnector Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package de.akquinet.jbosscc.guttenbase.connector.impl;

import java.sql.Connection;
import java.sql.SQLException;

import org.apache.log4j.Logger;

import de.akquinet.jbosscc.guttenbase.repository.ConnectorRepository;

/**
 * Connection info via data source and optional user/password.
 * 
 * 

* © 2012-2020 akquinet tech@spree *

* * @author M. Dahm */ public class DataSourceConnector extends AbstractConnector { protected static final Logger LOG = Logger.getLogger(DataSourceConnector.class); private final DataSourceConnectorInfo _dataSourceConnectionInfo; public DataSourceConnector(final ConnectorRepository connectorRepository, final String connectorId, final DataSourceConnectorInfo dataSourceConnectionInfo) { super(connectorRepository, connectorId, dataSourceConnectionInfo); assert dataSourceConnectionInfo != null : "dataSourceConnectionInfo != null"; _dataSourceConnectionInfo = dataSourceConnectionInfo; } /** * {@inheritDoc} */ @Override public Connection openConnection() throws SQLException { if (_connection == null || _connection.isClosed()) { if (_dataSourceConnectionInfo.getUser() != null && _dataSourceConnectionInfo.getPassword() != null) { _connection = _dataSourceConnectionInfo.getDataSource().getConnection(_dataSourceConnectionInfo.getUser(), _dataSourceConnectionInfo.getPassword()); } else { _connection = _dataSourceConnectionInfo.getDataSource().getConnection(); } } return _connection; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy