package org.jboss.resource.adapter.jdbc;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.resource.Referenceable;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ConnectionRequestInfo;
import javax.sql.DataSource;
import org.jboss.util.NestedSQLException;
import java.io.Serializable;
public class WrapperDataSource
implements Referenceable, DataSource, Serializable
{
static final long serialVersionUID = 3570285419164793501L;
private final BaseWrapperManagedConnectionFactory mcf;
private final ConnectionManager cm;
private Reference reference;
public WrapperDataSource (final BaseWrapperManagedConnectionFactory mcf, final ConnectionManager cm)
{
this.mcf = mcf;
this.cm = cm;
}
public PrintWriter getLogWriter() throws SQLException
{
return null;
}
public void setLogWriter(PrintWriter param1) throws SQLException
{
}
public int getLoginTimeout() throws SQLException
{
return 0;
}
public void setLoginTimeout(int param1) throws SQLException
{
}
public Connection getConnection() throws SQLException
{
try
{
return (Connection)cm.allocateConnection(mcf, null);
}
catch (ResourceException re)
{
throw new NestedSQLException(re);
} }
public Connection getConnection(String user, String password) throws SQLException
{
ConnectionRequestInfo cri = new WrappedConnectionRequestInfo(user, password);
try
{
return (Connection)cm.allocateConnection(mcf, cri);
}
catch (ResourceException re)
{
throw new NestedSQLException(re);
} }
public void setReference(final Reference reference)
{
this.reference = reference;
}
public Reference getReference()
{
return reference;
}
}