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

org.javasimon.jdbcx.WrappingSimonDataSource Maven / Gradle / Ivy

The newest version!
package org.javasimon.jdbcx;

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

import javax.sql.DataSource;

import org.javasimon.jdbc.SimonConnection;

/**
 * WrappingSimonDataSource allows to wrap existing datasource instead of providing
 * the Driver and URL information. For example - it can be used with Spring easily:
 * 
{@literal
 * 
 * 
 * 
 * 
 * 

* * * * * * * * }

* * @author diroussel * @version $Revision$ $Date$ * @since 2.2 */ public class WrappingSimonDataSource extends AbstractSimonDataSource implements DataSource { private DataSource ds; public DataSource getDataSource() { return ds; } public void setDataSource(DataSource ds) { this.ds = ds; } /** *

Attempts to establish a connection with the data source that * this DataSource object represents. * * @return a connection to the data source * @throws SQLException if a database access error occurs */ public Connection getConnection() throws SQLException { return new SimonConnection(getDataSource().getConnection(), prefix); } /** *

Attempts to establish a connection with the data source that * this DataSource object represents. * * @param user the database user on whose behalf the connection is being made * @param password the user's password * @return a connection to the data source * @throws SQLException if a database access error occurs */ public Connection getConnection(String user, String password) throws SQLException { return new SimonConnection(getDataSource().getConnection(user, password), prefix); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy