jboss-common-jdbc-wrapper

16:37:17.955 INFO  jd.cli.Main - Decompiling jboss-common-jdbc-wrapper.jar
package org.jboss.resource.adapter.jdbc;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Savepoint;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEvent;
import javax.resource.spi.ConnectionEventListener;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionMetaData;
import javax.security.auth.Subject;
import org.jboss.logging.Logger;
import org.jboss.resource.JBossResourceException;

public abstract class BaseWrapperManagedConnection
  implements ManagedConnection
{
  protected final BaseWrapperManagedConnectionFactory mcf;
  protected final Connection con;
  protected final Properties props;
  private final int transactionIsolation;
  private final boolean readOnly;
  private final Collection cels = new ArrayList();
  private final Set handles = new HashSet();
  private PreparedStatementCache psCache = null;
  protected Object stateLock = new Object();
  protected boolean inManagedTransaction = false;
  protected boolean jdbcAutoCommit = true;
  protected boolean underlyingAutoCommit = true;
  protected boolean jdbcReadOnly;
  protected boolean underlyingReadOnly;
  protected int jdbcTransactionIsolation;
  protected boolean destroyed = false;
  protected boolean setQueryTimeout = false;
  
  public BaseWrapperManagedConnection(BaseWrapperManagedConnectionFactory mcf, Connection con, Properties props, int transactionIsolation, int psCacheSize, boolean qTimeout)
    throws SQLException
  {
    this.mcf = mcf;
    if (System.getSecurityManager() != null)
    {
      PrivilegedProxy proxy = new PrivilegedProxy(con);
      try
      {
        this.con = ((Connection)proxy.getProxy());
      }
      catch (Exception e)
      {
        throw new SQLException("Failed to create Connection proxy" + e.getMessage());
      }
    }
    else
    {
      this.con = con;
    }
    this.props = props;
    setQueryTimeout = qTimeout;
    if (psCacheSize > 0) {
      psCache = new PreparedStatementCache(psCacheSize);
    }
    if (transactionIsolation == -1)
    {
      this.transactionIsolation = con.getTransactionIsolation();
    }
    else
    {
      this.transactionIsolation = transactionIsolation;
      con.setTransactionIsolation(transactionIsolation);
    }
    readOnly = con.isReadOnly();
    if (mcf.getNewConnectionSQL() != null)
    {
      Statement s = con.createStatement();
      try
      {
        s.execute(mcf.getNewConnectionSQL());
      }
      finally
      {
        s.close();
      }
    }
    underlyingReadOnly = readOnly;
    jdbcReadOnly = readOnly;
    jdbcTransactionIsolation = this.transactionIsolation;
  }
  
  public void addConnectionEventListener(ConnectionEventListener cel)
  {
    synchronized (cels)
    {
      cels.add(cel);
    }
  }
  
  public void removeConnectionEventListener(ConnectionEventListener cel)
  {
    synchronized (cels)
    {
      cels.remove(cel);
    }
  }
  
  public void associateConnection(Object handle)
    throws ResourceException
  {
    if (!(handle instanceof WrappedConnection)) {
      throw new JBossResourceException("Wrong kind of connection handle to associate" + handle);
    }
    ((WrappedConnection)handle).setManagedConnection(this);
    synchronized (handles)
    {
      handles.add(handle);
    }
  }
  
  public PrintWriter getLogWriter()
    throws ResourceException
  {
    return null;
  }
  
  public ManagedConnectionMetaData getMetaData()
    throws ResourceException
  {
    return null;
  }
  
  public void setLogWriter(PrintWriter param1)
    throws ResourceException
  {}
  
  public void cleanup()
    throws ResourceException
  {
    synchronized (handles)
    {
      for (Iterator i = handles.iterator(); i.hasNext();)
      {
        WrappedConnection lc = (WrappedConnection)i.next();
        lc.setManagedConnection(null);
      }
      handles.clear();
    }
    synchronized (stateLock)
    {
      jdbcAutoCommit = true;
      jdbcReadOnly = readOnly;
      if (jdbcTransactionIsolation != transactionIsolation) {
        try
        {
          con.setTransactionIsolation(jdbcTransactionIsolation);
          jdbcTransactionIsolation = transactionIsolation;
        }
        catch (SQLException e)
        {
          mcf.log.warn("Error resetting transaction isolation ", e);
        }
      }
    }
  }
  
  public Object getConnection(Subject subject, ConnectionRequestInfo cri)
    throws ResourceException
  {
    checkIdentity(subject, cri);
    WrappedConnection lc = new WrappedConnection(this, setQueryTimeout);
    synchronized (handles)
    {
      handles.add(lc);
    }
    return lc;
  }
  
  public void destroy()
    throws ResourceException
  {
    destroyed = true;
    
    cleanup();
    if (psCache != null) {
      psCache.flush();
    }
    try
    {
      con.close();
    }
    catch (SQLException e)
    {
      checkException(e);
    }
  }
  
  public boolean checkValid()
  {
    SQLException e = mcf.isValidConnection(con);
    if (e == null) {
      return true;
    }
    mcf.log.warn("Destroying connection that is not valid, due to the following exception:", e);
    broadcastConnectionError(e);
    return false;
  }
  
  void closeHandle(WrappedConnection handle)
  {
    if (destroyed) {
      return;
    }
    synchronized (handles)
    {
      handles.remove(handle);
    }
    ConnectionEvent ce = new ConnectionEvent(this, 1);
    ce.setConnectionHandle(handle);
    Object copy = null;
    synchronized (cels)
    {
      copy = new ArrayList(cels);
    }
    for (Iterator i = ((Collection)copy).iterator(); i.hasNext();)
    {
      ConnectionEventListener cel = (ConnectionEventListener)i.next();
      cel.connectionClosed(ce);
    }
  }
  
  void connectionError(SQLException e)
  {
    if (mcf.isExceptionFatal(e)) {
      broadcastConnectionError(e);
    }
  }
  
  protected void broadcastConnectionError(SQLException e)
  {
    ConnectionEvent ce = new ConnectionEvent(this, 5, e);
    Collection copy = null;
    synchronized (cels)
    {
      copy = new ArrayList(cels);
    }
    for (Iterator i = copy.iterator(); i.hasNext();)
    {
      ConnectionEventListener cel = (ConnectionEventListener)i.next();
      cel.connectionErrorOccurred(ce);
    }
  }
  
  Connection getConnection()
    throws SQLException
  {
    if (con == null) {
      throw new SQLException("Connection has been destroyed!!!");
    }
    return con;
  }
  
  PreparedStatement prepareStatement(String sql)
    throws SQLException
  {
    if (psCache != null)
    {
      CachedPreparedStatement cachedps = (CachedPreparedStatement)psCache.get(sql);
      if (cachedps != null)
      {
        cachedps.inUse();
      }
      else
      {
        PreparedStatement ps = con.prepareStatement(sql);
        cachedps = new CachedPreparedStatement(ps);
        psCache.insert(sql, cachedps);
      }
      return cachedps;
    }
    return con.prepareStatement(sql);
  }
  
  protected Logger getLog()
  {
    return mcf.log;
  }
  
  private void checkIdentity(Subject subject, ConnectionRequestInfo cri)
    throws ResourceException
  {
    Properties newProps = mcf.getConnectionProperties(subject, cri);
    if (!props.equals(newProps)) {
      throw new JBossResourceException("Wrong credentials passed to getConnection!");
    }
  }
  
  void checkTransaction()
    throws SQLException
  {
    synchronized (stateLock)
    {
      if (inManagedTransaction) {
        return;
      }
      if (jdbcAutoCommit != underlyingAutoCommit)
      {
        con.setAutoCommit(jdbcAutoCommit);
        underlyingAutoCommit = jdbcAutoCommit;
      }
    }
    checkState();
  }
  
  protected void checkState()
    throws SQLException
  {
    synchronized (stateLock)
    {
      if (jdbcReadOnly != underlyingReadOnly)
      {
        con.setReadOnly(jdbcReadOnly);
        underlyingReadOnly = jdbcReadOnly;
      }
    }
  }
  
  boolean isJdbcAutoCommit()
  {
    return inManagedTransaction ? false : jdbcAutoCommit;
  }
  
  void setJdbcAutoCommit(boolean jdbcAutoCommit)
    throws SQLException
  {
    synchronized (stateLock)
    {
      if (inManagedTransaction) {
        throw new SQLException("You cannot set autocommit during a managed transaction!");
      }
      this.jdbcAutoCommit = jdbcAutoCommit;
    }
  }
  
  boolean isJdbcReadOnly()
  {
    return jdbcReadOnly;
  }
  
  void setJdbcReadOnly(boolean readOnly)
    throws SQLException
  {
    synchronized (stateLock)
    {
      if (inManagedTransaction) {
        throw new SQLException("You cannot set read only during a managed transaction!");
      }
      jdbcReadOnly = readOnly;
    }
  }
  
  int getJdbcTransactionIsolation()
  {
    return jdbcTransactionIsolation;
  }
  
  void setJdbcTransactionIsolation(int isolationLevel)
    throws SQLException
  {
    synchronized (stateLock)
    {
      jdbcTransactionIsolation = isolationLevel;
      con.setTransactionIsolation(jdbcTransactionIsolation);
    }
  }
  
  void jdbcCommit()
    throws SQLException
  {
    synchronized (stateLock)
    {
      if (inManagedTransaction) {
        throw new SQLException("You cannot commit during a managed transaction!");
      }
      if (jdbcAutoCommit) {
        throw new SQLException("You cannot commit with autocommit set!");
      }
    }
    con.commit();
  }
  
  void jdbcRollback()
    throws SQLException
  {
    synchronized (stateLock)
    {
      if (inManagedTransaction) {
        throw new SQLException("You cannot rollback during a managed transaction!");
      }
      if (jdbcAutoCommit) {
        throw new SQLException("You cannot rollback with autocommit set!");
      }
    }
    con.rollback();
  }
  
  void jdbcRollback(Savepoint savepoint)
    throws SQLException
  {
    synchronized (stateLock)
    {
      if (inManagedTransaction) {
        throw new SQLException("You cannot rollback during a managed transaction!");
      }
      if (jdbcAutoCommit) {
        throw new SQLException("You cannot rollback with autocommit set!");
      }
    }
    con.rollback(savepoint);
  }
  
  int getTrackStatements()
  {
    return mcf.trackStatements;
  }
  
  protected void checkException(SQLException e)
    throws ResourceException
  {
    connectionError(e);
    throw new JBossResourceException("SQLException", e);
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.security.PasswordCredential;
import javax.security.auth.Subject;

class BaseWrapperManagedConnectionFactory$SubjectActions
  implements PrivilegedAction
{
  Subject subject;
  Properties props;
  ManagedConnectionFactory mcf;
  
  BaseWrapperManagedConnectionFactory$SubjectActions(Subject subject, Properties props, ManagedConnectionFactory mcf)
  {
    this.subject = subject;
    this.props = props;
    this.mcf = mcf;
  }
  
  public Object run()
  {
    Iterator i = subject.getPrivateCredentials().iterator();
    while (i.hasNext())
    {
      Object o = i.next();
      if ((o instanceof PasswordCredential))
      {
        PasswordCredential cred = (PasswordCredential)o;
        if (cred.getManagedConnectionFactory().equals(mcf))
        {
          props.setProperty("user", cred.getUserName() == null ? "" : cred.getUserName());
          props.setProperty("password", new String(cred.getPassword()));
          return Boolean.TRUE;
        }
      }
    }
    return Boolean.FALSE;
  }
  
  static boolean addMatchingProperties(Subject subject, Properties props, ManagedConnectionFactory mcf)
  {
    SubjectActions action = new SubjectActions(subject, props, mcf);
    Boolean matched = (Boolean)AccessController.doPrivileged(action);
    return matched.booleanValue();
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.SubjectActions
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.io.PrintWriter;
import java.io.Serializable;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.security.PasswordCredential;
import javax.security.auth.Subject;
import org.jboss.logging.Logger;
import org.jboss.resource.JBossResourceException;

public abstract class BaseWrapperManagedConnectionFactory
  implements ManagedConnectionFactory, Serializable
{
  public static final int TRACK_STATEMENTS_FALSE_INT = 0;
  public static final int TRACK_STATEMENTS_TRUE_INT = 1;
  public static final int TRACK_STATEMENTS_NOWARN_INT = 2;
  public static final String TRACK_STATEMENTS_FALSE = "false";
  public static final String TRACK_STATEMENTS_TRUE = "true";
  public static final String TRACK_STATEMENTS_NOWARN = "nowarn";
  protected final Logger log = Logger.getLogger(getClass());
  protected String userName;
  protected String password;
  protected HashMap connectionProps = new HashMap();
  protected int transactionIsolation = -1;
  protected int preparedStatementCacheSize = 0;
  protected boolean doQueryTimeout = false;
  protected String newConnectionSQL;
  protected String checkValidConnectionSQL;
  protected String validConnectionCheckerClassName;
  protected ValidConnectionChecker connectionChecker;
  private String exceptionSorterClassName;
  private ExceptionSorter exceptionSorter;
  protected int trackStatements = 2;
  
  public PrintWriter getLogWriter()
    throws ResourceException
  {
    return null;
  }
  
  public void setLogWriter(PrintWriter param1)
    throws ResourceException
  {}
  
  public Object createConnectionFactory(ConnectionManager cm)
    throws ResourceException
  {
    return new WrapperDataSource(this, cm);
  }
  
  public Object createConnectionFactory()
    throws ResourceException
  {
    throw new JBossResourceException("NYI");
  }
  
  public String getUserName()
  {
    return userName;
  }
  
  public void setUserName(String userName)
  {
    this.userName = userName;
  }
  
  public String getPassword()
  {
    return password;
  }
  
  public void setPassword(String password)
  {
    this.password = password;
  }
  
  public int getPreparedStatementCacheSize()
  {
    return preparedStatementCacheSize;
  }
  
  public void setPreparedStatementCacheSize(int size)
  {
    preparedStatementCacheSize = size;
  }
  
  public boolean getTxQueryTimeout()
  {
    return doQueryTimeout;
  }
  
  public void setTxQueryTimeout(boolean qt)
  {
    doQueryTimeout = qt;
  }
  
  public String getTransactionIsolation()
  {
    switch (transactionIsolation)
    {
    case 0: 
      return "TRANSACTION_NONE";
    case 2: 
      return "TRANSACTION_READ_COMMITTED";
    case 1: 
      return "TRANSACTION_READ_UNCOMMITTED";
    case 4: 
      return "TRANSACTION_REPEATABLE_READ";
    case 8: 
      return "TRANSACTION_SERIALIZABLE";
    case -1: 
      return "DEFAULT";
    }
    return Integer.toString(transactionIsolation);
  }
  
  public void setTransactionIsolation(String transactionIsolation)
  {
    if (transactionIsolation.equals("TRANSACTION_NONE")) {
      this.transactionIsolation = 0;
    } else if (transactionIsolation.equals("TRANSACTION_READ_COMMITTED")) {
      this.transactionIsolation = 2;
    } else if (transactionIsolation.equals("TRANSACTION_READ_UNCOMMITTED")) {
      this.transactionIsolation = 1;
    } else if (transactionIsolation.equals("TRANSACTION_REPEATABLE_READ")) {
      this.transactionIsolation = 4;
    } else if (transactionIsolation.equals("TRANSACTION_SERIALIZABLE")) {
      this.transactionIsolation = 8;
    } else {
      try
      {
        this.transactionIsolation = Integer.parseInt(transactionIsolation);
      }
      catch (NumberFormatException nfe)
      {
        throw new IllegalArgumentException("Setting Isolation level to unknown state: " + transactionIsolation);
      }
    }
  }
  
  public String getNewConnectionSQL()
  {
    return newConnectionSQL;
  }
  
  public void setNewConnectionSQL(String newConnectionSQL)
  {
    this.newConnectionSQL = newConnectionSQL;
  }
  
  public String getCheckValidConnectionSQL()
  {
    return checkValidConnectionSQL;
  }
  
  public void setCheckValidConnectionSQL(String checkValidConnectionSQL)
  {
    this.checkValidConnectionSQL = checkValidConnectionSQL;
  }
  
  public String getTrackStatements()
  {
    if (trackStatements == 0) {
      return "false";
    }
    if (trackStatements == 1) {
      return "true";
    }
    return "nowarn";
  }
  
  public void setTrackStatements(String value)
  {
    if (value == null) {
      throw new IllegalArgumentException("Null value for trackStatements");
    }
    String trimmed = value.trim();
    if (trimmed.equalsIgnoreCase("false")) {
      trackStatements = 0;
    } else if (trimmed.equalsIgnoreCase("true")) {
      trackStatements = 1;
    } else {
      trackStatements = 2;
    }
  }
  
  public String getExceptionSorterClassName()
  {
    return exceptionSorterClassName;
  }
  
  public void setExceptionSorterClassName(String exceptionSorterClassName)
  {
    this.exceptionSorterClassName = exceptionSorterClassName;
  }
  
  public String getValidConnectionCheckerClassName()
  {
    return validConnectionCheckerClassName;
  }
  
  public void setValidConnectionCheckerClassName(String value)
  {
    validConnectionCheckerClassName = value;
  }
  
  protected Properties getConnectionProperties(Subject subject, ConnectionRequestInfo cri)
    throws ResourceException
  {
    if ((cri != null) && (cri.getClass() != WrappedConnectionRequestInfo.class)) {
      throw new JBossResourceException("Wrong kind of ConnectionRequestInfo: " + cri.getClass());
    }
    Properties props = new Properties();
    props.putAll(connectionProps);
    if (subject != null)
    {
      if (SubjectActions.addMatchingProperties(subject, props, this) == true) {
        return props;
      }
      throw new JBossResourceException("No matching credentials in Subject!");
    }
    WrappedConnectionRequestInfo lcri = (WrappedConnectionRequestInfo)cri;
    if (lcri != null)
    {
      props.setProperty("user", lcri.getUserName() == null ? "" : lcri.getUserName());
      props.setProperty("password", lcri.getPassword() == null ? "" : lcri.getPassword());
      return props;
    }
    if (userName != null)
    {
      props.setProperty("user", userName);
      props.setProperty("password", password == null ? "" : password);
    }
    return props;
  }
  
  boolean isExceptionFatal(SQLException e)
  {
    if (exceptionSorter != null) {
      return exceptionSorter.isExceptionFatal(e);
    }
    if (exceptionSorterClassName != null) {
      try
      {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        Class clazz = cl.loadClass(exceptionSorterClassName);
        exceptionSorter = ((ExceptionSorter)clazz.newInstance());
        return exceptionSorter.isExceptionFatal(e);
      }
      catch (Exception e2)
      {
        log.warn("exception trying to create exception sorter (disabling):", e2);
        exceptionSorter = new NullExceptionSorter();
      }
    }
    return false;
  }
  
  SQLException isValidConnection(Connection c)
  {
    if (connectionChecker != null) {
      return connectionChecker.isValidConnection(c);
    }
    if (validConnectionCheckerClassName != null) {
      try
      {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        Class clazz = cl.loadClass(validConnectionCheckerClassName);
        connectionChecker = ((ValidConnectionChecker)clazz.newInstance());
        return connectionChecker.isValidConnection(c);
      }
      catch (Exception e)
      {
        log.warn("Exception trying to create connection checker (disabling):", e);
        connectionChecker = new NullValidConnectionChecker();
      }
    }
    if (checkValidConnectionSQL != null)
    {
      connectionChecker = new CheckValidConnectionSQL(checkValidConnectionSQL);
      return connectionChecker.isValidConnection(c);
    }
    return null;
  }
  
  static class SubjectActions
    implements PrivilegedAction
  {
    Subject subject;
    Properties props;
    ManagedConnectionFactory mcf;
    
    SubjectActions(Subject subject, Properties props, ManagedConnectionFactory mcf)
    {
      this.subject = subject;
      this.props = props;
      this.mcf = mcf;
    }
    
    public Object run()
    {
      Iterator i = subject.getPrivateCredentials().iterator();
      while (i.hasNext())
      {
        Object o = i.next();
        if ((o instanceof PasswordCredential))
        {
          PasswordCredential cred = (PasswordCredential)o;
          if (cred.getManagedConnectionFactory().equals(mcf))
          {
            props.setProperty("user", cred.getUserName() == null ? "" : cred.getUserName());
            props.setProperty("password", new String(cred.getPassword()));
            return Boolean.TRUE;
          }
        }
      }
      return Boolean.FALSE;
    }
    
    static boolean addMatchingProperties(Subject subject, Properties props, ManagedConnectionFactory mcf)
    {
      SubjectActions action = new SubjectActions(subject, props, mcf);
      Boolean matched = (Boolean)AccessController.doPrivileged(action);
      return matched.booleanValue();
    }
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;

public class CachedPreparedStatement
  implements PreparedStatement
{
  private PreparedStatement ps;
  private SynchronizedBoolean cached = new SynchronizedBoolean(true);
  private SynchronizedInt inUse = new SynchronizedInt(1);
  private int defaultMaxFieldSize;
  private int defaultMaxRows;
  private int defaultQueryTimeout;
  private int defaultFetchDirection;
  private int defaultFetchSize;
  private int currentMaxFieldSize;
  private int currentMaxRows;
  private int currentQueryTimeout;
  private int currentFetchDirection;
  private int currentFetchSize;
  
  public CachedPreparedStatement(PreparedStatement ps)
    throws SQLException
  {
    this.ps = ps;
    
    defaultMaxFieldSize = ps.getMaxFieldSize();
    defaultMaxRows = ps.getMaxRows();
    defaultQueryTimeout = ps.getQueryTimeout();
    defaultFetchDirection = 1000;
    defaultFetchSize = 0;
    currentMaxFieldSize = defaultMaxFieldSize;
    currentMaxRows = defaultMaxRows;
    currentQueryTimeout = defaultQueryTimeout;
    currentFetchDirection = defaultFetchDirection;
    currentFetchSize = defaultFetchSize;
  }
  
  public PreparedStatement getUnderlyingPreparedStatement()
  {
    return ps;
  }
  
  public ResultSet executeQuery()
    throws SQLException
  {
    return ps.executeQuery();
  }
  
  public int executeUpdate()
    throws SQLException
  {
    return ps.executeUpdate();
  }
  
  public void setNull(int parameterIndex, int sqlType)
    throws SQLException
  {
    ps.setNull(parameterIndex, sqlType);
  }
  
  public void setBoolean(int parameterIndex, boolean x)
    throws SQLException
  {
    ps.setBoolean(parameterIndex, x);
  }
  
  public void setByte(int parameterIndex, byte x)
    throws SQLException
  {
    ps.setByte(parameterIndex, x);
  }
  
  public void setShort(int parameterIndex, short x)
    throws SQLException
  {
    ps.setShort(parameterIndex, x);
  }
  
  public void setInt(int parameterIndex, int x)
    throws SQLException
  {
    ps.setInt(parameterIndex, x);
  }
  
  public void setLong(int parameterIndex, long x)
    throws SQLException
  {
    ps.setLong(parameterIndex, x);
  }
  
  public void setFloat(int parameterIndex, float x)
    throws SQLException
  {
    ps.setFloat(parameterIndex, x);
  }
  
  public void setDouble(int parameterIndex, double x)
    throws SQLException
  {
    ps.setDouble(parameterIndex, x);
  }
  
  public void setBigDecimal(int parameterIndex, BigDecimal x)
    throws SQLException
  {
    ps.setBigDecimal(parameterIndex, x);
  }
  
  public void setString(int parameterIndex, String x)
    throws SQLException
  {
    ps.setString(parameterIndex, x);
  }
  
  public void setBytes(int parameterIndex, byte[] x)
    throws SQLException
  {
    ps.setBytes(parameterIndex, x);
  }
  
  public void setDate(int parameterIndex, Date x)
    throws SQLException
  {
    ps.setDate(parameterIndex, x);
  }
  
  public void setTime(int parameterIndex, Time x)
    throws SQLException
  {
    ps.setTime(parameterIndex, x);
  }
  
  public void setTimestamp(int parameterIndex, Timestamp x)
    throws SQLException
  {
    ps.setTimestamp(parameterIndex, x);
  }
  
  public void setAsciiStream(int parameterIndex, InputStream x, int length)
    throws SQLException
  {
    ps.setAsciiStream(parameterIndex, x, length);
  }
  
  public void setUnicodeStream(int parameterIndex, InputStream x, int length)
    throws SQLException
  {
    ps.setUnicodeStream(parameterIndex, x, length);
  }
  
  public void setBinaryStream(int parameterIndex, InputStream x, int length)
    throws SQLException
  {
    ps.setBinaryStream(parameterIndex, x, length);
  }
  
  public void clearParameters()
    throws SQLException
  {
    ps.clearParameters();
  }
  
  public void setObject(int parameterIndex, Object x, int targetSqlType, int scale)
    throws SQLException
  {
    ps.setObject(parameterIndex, x, targetSqlType, scale);
  }
  
  public void setObject(int parameterIndex, Object x, int targetSqlType)
    throws SQLException
  {
    ps.setObject(parameterIndex, x, targetSqlType);
  }
  
  public void setObject(int parameterIndex, Object x)
    throws SQLException
  {
    ps.setObject(parameterIndex, x);
  }
  
  public boolean execute()
    throws SQLException
  {
    return ps.execute();
  }
  
  public void addBatch()
    throws SQLException
  {
    ps.addBatch();
  }
  
  public void setCharacterStream(int parameterIndex, Reader reader, int length)
    throws SQLException
  {
    ps.setCharacterStream(parameterIndex, reader, length);
  }
  
  public void setRef(int i, Ref x)
    throws SQLException
  {
    ps.setRef(i, x);
  }
  
  public void setBlob(int i, Blob x)
    throws SQLException
  {
    ps.setBlob(i, x);
  }
  
  public void setClob(int i, Clob x)
    throws SQLException
  {
    ps.setClob(i, x);
  }
  
  public void setArray(int i, Array x)
    throws SQLException
  {
    ps.setArray(i, x);
  }
  
  public ResultSetMetaData getMetaData()
    throws SQLException
  {
    return ps.getMetaData();
  }
  
  public void setDate(int parameterIndex, Date x, Calendar cal)
    throws SQLException
  {
    ps.setDate(parameterIndex, x, cal);
  }
  
  public void setTime(int parameterIndex, Time x, Calendar cal)
    throws SQLException
  {
    ps.setTime(parameterIndex, x, cal);
  }
  
  public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
    throws SQLException
  {
    ps.setTimestamp(parameterIndex, x, cal);
  }
  
  public void setNull(int paramIndex, int sqlType, String typeName)
    throws SQLException
  {
    ps.setNull(paramIndex, sqlType, typeName);
  }
  
  public void setURL(int parameterIndex, URL x)
    throws SQLException
  {
    ps.setURL(parameterIndex, x);
  }
  
  public ParameterMetaData getParameterMetaData()
    throws SQLException
  {
    return ps.getParameterMetaData();
  }
  
  public ResultSet executeQuery(String sql)
    throws SQLException
  {
    return ps.executeQuery(sql);
  }
  
  public int executeUpdate(String sql)
    throws SQLException
  {
    return ps.executeUpdate(sql);
  }
  
  public void inUse()
  {
    inUse.increment();
  }
  
  public void agedOut()
    throws SQLException
  {
    cached.set(false);
    if (inUse.get() == 0) {
      ps.close();
    }
  }
  
  public void close()
    throws SQLException
  {
    inUse.decrement();
    if (inUse.get() == 0) {
      if (!cached.get())
      {
        ps.close();
      }
      else
      {
        if (defaultMaxFieldSize != currentMaxFieldSize)
        {
          ps.setMaxFieldSize(defaultMaxFieldSize);
          currentMaxFieldSize = defaultMaxFieldSize;
        }
        if (defaultMaxRows != currentMaxRows)
        {
          ps.setMaxRows(defaultMaxRows);
          currentMaxRows = defaultMaxRows;
        }
        if (defaultQueryTimeout != currentQueryTimeout)
        {
          ps.setQueryTimeout(defaultQueryTimeout);
          currentQueryTimeout = defaultQueryTimeout;
        }
        if (defaultFetchDirection != currentFetchDirection)
        {
          ps.setFetchDirection(defaultFetchDirection);
          currentFetchDirection = defaultFetchDirection;
        }
        if (defaultFetchSize != currentFetchSize)
        {
          ps.setFetchSize(defaultFetchSize);
          currentFetchSize = defaultFetchSize;
        }
      }
    }
  }
  
  public int getMaxFieldSize()
    throws SQLException
  {
    return ps.getMaxFieldSize();
  }
  
  public void setMaxFieldSize(int max)
    throws SQLException
  {
    ps.setMaxFieldSize(max);
    currentMaxFieldSize = max;
  }
  
  public int getMaxRows()
    throws SQLException
  {
    return ps.getMaxRows();
  }
  
  public void setMaxRows(int max)
    throws SQLException
  {
    ps.setMaxRows(max);
    currentMaxRows = max;
  }
  
  public void setEscapeProcessing(boolean enable)
    throws SQLException
  {
    ps.setEscapeProcessing(enable);
  }
  
  public int getQueryTimeout()
    throws SQLException
  {
    return ps.getQueryTimeout();
  }
  
  public void setQueryTimeout(int seconds)
    throws SQLException
  {
    ps.setQueryTimeout(seconds);
    currentQueryTimeout = seconds;
  }
  
  public void cancel()
    throws SQLException
  {
    ps.cancel();
  }
  
  public SQLWarning getWarnings()
    throws SQLException
  {
    return ps.getWarnings();
  }
  
  public void clearWarnings()
    throws SQLException
  {
    ps.clearWarnings();
  }
  
  public void setCursorName(String name)
    throws SQLException
  {
    ps.setCursorName(name);
  }
  
  public boolean execute(String sql)
    throws SQLException
  {
    return ps.execute(sql);
  }
  
  public ResultSet getResultSet()
    throws SQLException
  {
    return ps.getResultSet();
  }
  
  public int getUpdateCount()
    throws SQLException
  {
    return ps.getUpdateCount();
  }
  
  public boolean getMoreResults()
    throws SQLException
  {
    return ps.getMoreResults();
  }
  
  public void setFetchDirection(int direction)
    throws SQLException
  {
    ps.setFetchDirection(direction);
    currentFetchDirection = direction;
  }
  
  public int getFetchDirection()
    throws SQLException
  {
    return ps.getFetchDirection();
  }
  
  public void setFetchSize(int rows)
    throws SQLException
  {
    ps.setFetchSize(rows);
    currentFetchSize = rows;
  }
  
  public int getFetchSize()
    throws SQLException
  {
    return ps.getFetchSize();
  }
  
  public int getResultSetConcurrency()
    throws SQLException
  {
    return ps.getResultSetConcurrency();
  }
  
  public int getResultSetType()
    throws SQLException
  {
    return ps.getResultSetType();
  }
  
  public void addBatch(String sql)
    throws SQLException
  {
    ps.addBatch(sql);
  }
  
  public void clearBatch()
    throws SQLException
  {
    ps.clearBatch();
  }
  
  public int[] executeBatch()
    throws SQLException
  {
    return ps.executeBatch();
  }
  
  public Connection getConnection()
    throws SQLException
  {
    return ps.getConnection();
  }
  
  public boolean getMoreResults(int current)
    throws SQLException
  {
    return ps.getMoreResults(current);
  }
  
  public ResultSet getGeneratedKeys()
    throws SQLException
  {
    return ps.getGeneratedKeys();
  }
  
  public int executeUpdate(String sql, int autoGeneratedKeys)
    throws SQLException
  {
    return ps.executeUpdate(sql, autoGeneratedKeys);
  }
  
  public int executeUpdate(String sql, int[] columnIndexes)
    throws SQLException
  {
    return ps.executeUpdate(sql, columnIndexes);
  }
  
  public int executeUpdate(String sql, String[] columnNames)
    throws SQLException
  {
    return ps.executeUpdate(sql, columnNames);
  }
  
  public boolean execute(String sql, int autoGeneratedKeys)
    throws SQLException
  {
    return ps.execute(sql, autoGeneratedKeys);
  }
  
  public boolean execute(String sql, int[] columnIndexes)
    throws SQLException
  {
    return ps.execute(sql, columnIndexes);
  }
  
  public boolean execute(String sql, String[] columnNames)
    throws SQLException
  {
    return ps.execute(sql, columnNames);
  }
  
  public int getResultSetHoldability()
    throws SQLException
  {
    return ps.getResultSetHoldability();
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.CachedPreparedStatement
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.io.Serializable;

public class CheckValidConnectionSQL
  implements ValidConnectionChecker, Serializable
{
  private static final long serialVersionUID = -222752863430216887L;
  String sql;
  
  public CheckValidConnectionSQL() {}
  
  public CheckValidConnectionSQL(String sql)
  {
    this.sql = sql;
  }
  
  /* Error */
  public java.sql.SQLException isValidConnection(java.sql.Connection c)
  {
    // Byte code:
    //   0: aload_1
    //   1: invokeinterface 3 1 0
    //   6: astore_2
    //   7: aload_2
    //   8: aload_0
    //   9: getfield 2	org/jboss/resource/adapter/jdbc/CheckValidConnectionSQL:sql	Ljava/lang/String;
    //   12: invokeinterface 4 2 0
    //   17: pop
    //   18: aconst_null
    //   19: astore_3
    //   20: aload_2
    //   21: invokeinterface 5 1 0
    //   26: aload_3
    //   27: areturn
    //   28: astore 4
    //   30: aload_2
    //   31: invokeinterface 5 1 0
    //   36: aload 4
    //   38: athrow
    //   39: astore_2
    //   40: aload_2
    //   41: areturn
    // Line number table:
    //   Java source line #41	-> byte code offset #0
    //   Java source line #44	-> byte code offset #7
    //   Java source line #45	-> byte code offset #18
    //   Java source line #49	-> byte code offset #20
    //   Java source line #52	-> byte code offset #39
    //   Java source line #54	-> byte code offset #40
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	42	0	this	CheckValidConnectionSQL
    //   0	42	1	c	java.sql.Connection
    //   6	25	2	s	java.sql.Statement
    //   39	2	2	e	java.sql.SQLException
    //   28	9	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	20	28	finally
    //   28	30	28	finally
    //   0	26	39	java/sql/SQLException
    //   28	39	39	java/sql/SQLException
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.CheckValidConnectionSQL
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.sql.SQLException;

public abstract interface ExceptionSorter
{
  public abstract boolean isExceptionFatal(SQLException paramSQLException);
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.ExceptionSorter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.sql.SQLException;

public class NullExceptionSorter
  implements ExceptionSorter
{
  public boolean isExceptionFatal(SQLException e)
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.NullExceptionSorter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;

public class NullValidConnectionChecker
  implements ValidConnectionChecker, Serializable
{
  private static final long serialVersionUID = -223752863430216887L;
  
  public SQLException isValidConnection(Connection c)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.NullValidConnectionChecker
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.sql.SQLException;
import org.jboss.logging.Logger;
import org.jboss.util.LRUCachePolicy;
import org.jboss.util.LRUCachePolicy.LRUCacheEntry;

public class PreparedStatementCache
  extends LRUCachePolicy
{
  private final Logger log = Logger.getLogger(getClass());
  
  public PreparedStatementCache(int max)
  {
    super(2, max);
    create();
  }
  
  protected void ageOut(LRUCachePolicy.LRUCacheEntry entry)
  {
    try
    {
      CachedPreparedStatement ws = (CachedPreparedStatement)m_object;
      ws.agedOut();
    }
    catch (SQLException e)
    {
      log.error("Failed closing cached statement", e);
    }
    finally
    {
      super.ageOut(entry);
    }
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.PreparedStatementCache
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.security.PrivilegedExceptionAction;
import java.util.HashSet;

class PrivilegedProxy$BuildProxyAction
  implements PrivilegedExceptionAction
{
  Object target;
  InvocationHandler handler;
  
  PrivilegedProxy$BuildProxyAction(Object target, InvocationHandler handler)
  {
    this.target = target;
    this.handler = handler;
  }
  
  public Object run()
    throws Exception
  {
    HashSet tmp = new HashSet();
    
    Class c = target.getClass();
    do
    {
      Class[] ifaces = c.getInterfaces();
      for (int i = 0; i < ifaces.length; i++)
      {
        Class iface = ifaces[i];
        int modifiers = iface.getModifiers();
        if (Modifier.isPublic(modifiers)) {
          tmp.add(iface);
        }
      }
      c = c.getSuperclass();
    } while (c != null);
    Class[] ifaces = new Class[tmp.size()];
    tmp.toArray(ifaces);
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    return Proxy.newProxyInstance(loader, ifaces, handler);
  }
}

/* Location:
 * Qualified Name:     org.jboss.resource.adapter.jdbc.PrivilegedProxy.BuildProxyAction
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.jboss.resource.adapter.jdbc;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Invocati
1 2 3 4

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd