KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mapper > dbms > JDBC2Connection


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.mapper.dbms;
24
25 import java.sql.*;
26
27 import org.xquark.jdbc.typing.DBMSInfo;
28
29 /**
30  * Base implementation of AbstractConnection for JDBC 2 databases.
31  *
32  * <p>This class is abstract because some methods like table creation
33  * are inevitably specific.</p>
34  */

35 public class JDBC2Connection extends DefaultConnectionImpl
36 {
37     private static final String JavaDoc RCSRevision = "$Revision: 1.2 $";
38     private static final String JavaDoc RCSName = "$Name: $";
39
40     public JDBC2Connection(Connection connection, short dbms)
41     throws SQLException
42     {
43         super(connection, dbms);
44     }
45
46     protected JDBC2Connection(Connection connection, short dbms, DBMSInfo dbmsInfo)
47     throws SQLException
48     {
49         super(connection, dbms, dbmsInfo);
50     }
51
52     /////////////////////////////////////////////////////
53
// JDBC2 specific methods
54
///////////////////////////////////////////////////////////////
55
/** Add a SQL statement in a batch for delayed execution.
56      * @param stmt the JDBC statement wich the SQL statement is to be added to
57      */

58     public void addBatch(PreparedStatement stmt) throws SQLException
59     {
60         stmt.addBatch();
61     }
62     
63     /** Add a SQL statement in a batch for delayed execution.
64      * @param stmt the JDBC statement which the SQL statement is to be added to
65      * @param SQLStatement the SQL statement that is to be added
66      */

67     public void addBatch(Statement stmt, String JavaDoc SQLStatement) throws SQLException
68     {
69         stmt.addBatch(SQLStatement);
70     }
71     /** Execute a batch created with the addBatch method.
72      * @param stmt the JDBC statement wich the SQL statement is to be added to
73      * @return an array of update counts containing one element for each command
74      * in the batch. The elements of the array are ordered according to the
75      * order in which commands were added to the batch.
76      */

77     public int[] executeBatch(Statement stmt) throws SQLException
78     {
79         int[] ret = stmt.executeBatch();
80         stmt.clearBatch();
81         return ret;
82     }
83     
84     /** Gives the JDBC driver a hint as to the number of rows that should be fetched
85      * from the database when more rows are needed.
86      * @param stmt the JDBC statement wich the SQL statement is to be added to
87      * @param rows the number of rows to fetch
88      */

89     public void setFetchSize(Statement stmt,int rows) throws SQLException
90     {
91         stmt.setFetchSize(rows);
92     }
93 }
94
Popular Tags