ConnectionResource.java revision 747
726N/A * The contents of this file are subject to the terms of the 726N/A * Common Development and Distribution License (the "License"). 726N/A * You may not use this file except in compliance with the License. 726N/A * language governing permissions and limitations under the License. 726N/A * When distributing Covered Code, include this CDDL HEADER in each 726N/A * If applicable, add the following below this CDDL HEADER, with the 726N/A * fields enclosed by brackets "[]" replaced with your own identifying 726N/A * information: Portions Copyright [yyyy] [name of copyright owner] 726N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 726N/A * Use is subject to license terms. 726N/A * Class that manages the resources associated with a database connection. 726N/A * This includes a cache of {@code PreparedStatement}s. 726N/A /** The connection to the database. */ 726N/A /** Statement cache. */ 726N/A * Create a new {@code ConnectionResource} instance. 726N/A * @param manager the {@code ConnectionManager} that created this object 726N/A * @throws SQLException if an error occurs when connecting to the database 726N/A * Commit the transaction. 726N/A * @throws SQLException if a database error occurs 726N/A * Abort the transaction. 726N/A * @throws SQLException if a database error occurs 726N/A * Get a {@code PreparedStatement} as defined by the specified 726N/A * {@code StatementCreator}. If it is the first time the statement 726N/A * creator is used on this {@code ConnectionResource}, the creator's 726N/A * {@link StatementCreator#create(Connection)} method is called to 726N/A * create a new {@code PreparedStatement}. This statement is cached, 726N/A * so that on subsequent calls with the same statement creator, the same 726N/A * {@code PreparedStatement} will be returned. 726N/A * @param creator object that specifies how to create the statement if 726N/A * @return a {@code PreparedStatement} object 726N/A * @throws SQLException if a database error occurs 728N/A // Should also check isClosed() here, but it's only available in 728N/A // JDK 6, so we can't. Anyway, callers shouldn't close the 728N/A // statements they get from this method. 726N/A * Create a new {@code Statement} object. 726N/A * @return a {@code Statement} object 726N/A * @throws java.sql.SQLException 747N/A * Prepare a statement. This method should only be used to prepare 747N/A * statements that are used infrequently. If a statement is likely to 747N/A * be used frequently, a {@code StatementCreator} object should be 747N/A * created for it, and the method {@link #getStatement(StatementCreator)} 747N/A * should be used instead. 747N/A * @param sql the SQL text to compile 747N/A * @return a prepared statement 747N/A * @throws SQLException if a database error occurs 747N/A * Get a meta-data object for the underlying connection. 747N/A * @return a {@code DatabaseMetaData} object 747N/A * @throws SQLException if a database error occurs