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

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

The newest version!
package de.akquinet.jbosscc.guttenbase.connector.impl;

import de.akquinet.jbosscc.guttenbase.repository.ConnectorRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

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

* © 2012-2034 akquinet tech@spree *

* * @author M. Dahm */ public class DataSourceConnector extends AbstractConnector { protected static final Logger LOG = LoggerFactory.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