1 | /* |
2 | |
3 | Derby - Class org.apache.derby.iapi.jdbc.BrokeredConnection30 |
4 | |
5 | Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.iapi.jdbc; |
22 | |
23 | import java.sql.Statement; |
24 | import java.sql.PreparedStatement; |
25 | import java.sql.CallableStatement; |
26 | import java.sql.SQLException; |
27 | import java.sql.Savepoint; |
28 | import org.apache.derby.iapi.reference.JDBC30Translation; |
29 | |
30 | /** |
31 | Extends BrokeredConnection to provide the JDBC 3.0 connection methods. |
32 | */ |
33 | public class BrokeredConnection30 extends BrokeredConnection |
34 | { |
35 | |
36 | public BrokeredConnection30(BrokeredConnectionControl control) |
37 | { |
38 | super(control); |
39 | } |
40 | |
41 | public final Statement createStatement(int resultSetType, |
42 | int resultSetConcurrency, |
43 | int resultSetHoldability) |
44 | throws SQLException { |
45 | try { |
46 | resultSetHoldability = statementHoldabilityCheck(resultSetHoldability); |
47 | return control.wrapStatement(getRealConnection().createStatement(resultSetType, |
48 | resultSetConcurrency, resultSetHoldability)); |
49 | } |
50 | catch (SQLException se) |
51 | { |
52 | notifyException(se); |
53 | throw se; |
54 | } |
55 | } |
56 | public final CallableStatement prepareCall(String sql, |
57 | int resultSetType, |
58 | int resultSetConcurrency, |
59 | int resultSetHoldability) |
60 | throws SQLException { |
61 | try { |
62 | resultSetHoldability = statementHoldabilityCheck(resultSetHoldability); |
63 | return control.wrapStatement( |
64 | getRealConnection().prepareCall(sql, resultSetType, |
65 | resultSetConcurrency, resultSetHoldability), sql); |
66 | } |
67 | catch (SQLException se) |
68 | { |
69 | notifyException(se); |
70 | throw se; |
71 | } |
72 | } |
73 | |
74 | public final Savepoint setSavepoint() |
75 | throws SQLException |
76 | { |
77 | try { |
78 | control.checkSavepoint(); |
79 | return getRealConnection().setSavepoint(); |
80 | } |
81 | catch (SQLException se) |
82 | { |
83 | notifyException(se); |
84 | throw se; |
85 | } |
86 | } |
87 | |
88 | public final Savepoint setSavepoint(String name) |
89 | throws SQLException |
90 | { |
91 | try { |
92 | control.checkSavepoint(); |
93 | return getRealConnection().setSavepoint(name); |
94 | } |
95 | catch (SQLException se) |
96 | { |
97 | notifyException(se); |
98 | throw se; |
99 | } |
100 | } |
101 | |
102 | public final void rollback(Savepoint savepoint) |
103 | throws SQLException |
104 | { |
105 | try { |
106 | control.checkRollback(); |
107 | getRealConnection().rollback(savepoint); |
108 | } |
109 | catch (SQLException se) |
110 | { |
111 | notifyException(se); |
112 | throw se; |
113 | } |
114 | } |
115 | |
116 | public final void releaseSavepoint(Savepoint savepoint) |
117 | throws SQLException |
118 | { |
119 | try { |
120 | getRealConnection().releaseSavepoint(savepoint); |
121 | } |
122 | catch (SQLException se) |
123 | { |
124 | notifyException(se); |
125 | throw se; |
126 | } |
127 | } |
128 | |
129 | |
130 | public final void setHoldability(int holdability) |
131 | throws SQLException |
132 | { |
133 | try { |
134 | holdability = control.checkHoldCursors(holdability, false); |
135 | getRealConnection().setHoldability(holdability); |
136 | stateHoldability = holdability; |
137 | } |
138 | catch (SQLException se) |
139 | { |
140 | notifyException(se); |
141 | throw se; |
142 | } |
143 | } |
144 | |
145 | public final PreparedStatement prepareStatement( |
146 | String sql, |
147 | int autoGeneratedKeys) |
148 | throws SQLException |
149 | { |
150 | try { |
151 | return control.wrapStatement(getRealConnection().prepareStatement(sql, autoGeneratedKeys), sql, new Integer(autoGeneratedKeys)); |
152 | } |
153 | catch (SQLException se) |
154 | { |
155 | notifyException(se); |
156 | throw se; |
157 | } |
158 | } |
159 | |
160 | public final PreparedStatement prepareStatement( |
161 | String sql, |
162 | int[] columnIndexes) |
163 | throws SQLException |
164 | { |
165 | try { |
166 | return control.wrapStatement(getRealConnection().prepareStatement(sql, columnIndexes), sql, columnIndexes); |
167 | } |
168 | catch (SQLException se) |
169 | { |
170 | notifyException(se); |
171 | throw se; |
172 | } |
173 | } |
174 | |
175 | public final PreparedStatement prepareStatement( |
176 | String sql, |
177 | String[] columnNames) |
178 | throws SQLException |
179 | { |
180 | try { |
181 | return control.wrapStatement(getRealConnection().prepareStatement(sql, columnNames), sql, columnNames); |
182 | } |
183 | catch (SQLException se) |
184 | { |
185 | notifyException(se); |
186 | throw se; |
187 | } |
188 | } |
189 | |
190 | public BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql, Object generatedKeys) throws SQLException { |
191 | return new BrokeredPreparedStatement30(statementControl, getJDBCLevel(), sql, generatedKeys); |
192 | } |
193 | public BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql) throws SQLException { |
194 | return new BrokeredCallableStatement30(statementControl, getJDBCLevel(), sql); |
195 | } |
196 | |
197 | int getJDBCLevel() { return 3;} |
198 | |
199 | } |