KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > jdbc > EmbedPreparedStatement20


1 /*
2
3    Derby - Class org.apache.derby.impl.jdbc.EmbedPreparedStatement20
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.jdbc;
23
24 import org.apache.derby.impl.jdbc.EmbedConnection;
25 import org.apache.derby.impl.jdbc.Util;
26
27 import org.apache.derby.iapi.sql.ResultSet;
28 import org.apache.derby.iapi.error.StandardException;
29
30 import org.apache.derby.iapi.reference.SQLState;
31
32 import java.io.InputStream JavaDoc;
33
34 import java.math.BigDecimal JavaDoc;
35
36 import java.sql.SQLException JavaDoc;
37 import java.sql.SQLWarning JavaDoc;
38 import java.sql.Date JavaDoc;
39 import java.sql.Time JavaDoc;
40 import java.sql.Timestamp JavaDoc;
41
42
43 /* ---- New jdbc 2.0 types ----- */
44 import java.sql.Array JavaDoc;
45 import java.sql.Blob JavaDoc;
46 import java.sql.Clob JavaDoc;
47 import java.sql.Ref JavaDoc;
48 import java.sql.Types JavaDoc;
49
50 /**
51  * This class extends the EmbedPreparedStatement class in order to support new
52  * methods and classes that come with JDBC 2.0.
53   <P><B>Supports</B>
54    <UL>
55    <LI> JDBC 2.0
56    </UL>
57  * @see org.apache.derby.impl.jdbc.EmbedPreparedStatement
58  *
59  * @author francois
60  */

61 public class EmbedPreparedStatement20
62     extends org.apache.derby.impl.jdbc.EmbedPreparedStatement {
63
64     //////////////////////////////////////////////////////////////
65
//
66
// CONSTRUCTORS
67
//
68
//////////////////////////////////////////////////////////////
69
/*
70         Constructor assumes caller will setup context stack
71         and restore it.
72         @exception SQLException on error
73      */

74     public EmbedPreparedStatement20 (EmbedConnection conn, String JavaDoc sql, boolean forMetaData,
75                                       int resultSetType,
76                                       int resultSetConcurrency,
77                                       int resultSetHoldability,
78                                       int autoGeneratedKeys,
79                                       int[] columnIndexes,
80                                       String JavaDoc[] columnNames)
81         throws SQLException JavaDoc {
82
83         super(conn, sql, forMetaData, resultSetType, resultSetConcurrency, resultSetHoldability,
84         autoGeneratedKeys, columnIndexes, columnNames);
85     }
86
87     /**
88      * JDBC 2.0
89      *
90      * Set a REF(&lt;structured-type&gt;) parameter.
91      *
92      * @param i the first parameter is 1, the second is 2, ...
93      * @param x an object representing data of an SQL REF Type
94      * @exception SQLException Feature not implemented for now.
95      */

96     public void setRef (int i, Ref JavaDoc x) throws SQLException JavaDoc {
97         throw Util.notImplemented();
98     }
99
100
101
102
103     /**
104      * JDBC 2.0
105      *
106      * Set an Array parameter.
107      *
108      * @param i the first parameter is 1, the second is 2, ...
109      * @param x an object representing an SQL array
110      * @exception SQLException Feature not implemented for now.
111      */

112     public void setArray (int i, Array JavaDoc x) throws SQLException JavaDoc {
113         throw Util.notImplemented();
114     }
115
116     /*
117     ** Methods using BigDecimal, moved out of EmbedPreparedStatement
118     ** to allow that class to support JSR169.
119     */

120     /**
121      * Set a parameter to a java.lang.BigDecimal value.
122      * The driver converts this to a SQL NUMERIC value when
123      * it sends it to the database.
124      *
125      * @param parameterIndex the first parameter is 1, the second is 2, ...
126      * @param x the parameter value
127      * @exception SQLException thrown on failure.
128      */

129     public final void setBigDecimal(int parameterIndex, BigDecimal JavaDoc x) throws SQLException JavaDoc {
130         checkStatus();
131         try {
132             /* JDBC is one-based, DBMS is zero-based */
133             getParms().getParameterForSet(parameterIndex - 1).setBigDecimal(x);
134
135         } catch (Throwable JavaDoc t) {
136             throw EmbedResultSet.noStateChangeException(t);
137         }
138     }
139
140     /**
141         Allow explict setObject conversions by sub-classes for classes
142         not supported by this variant. In this case handle BigDecimal.
143         @return true if the object was set successfully, false if no valid
144         conversion exists.
145
146         @exception SQLException value could not be set.
147     */

148     boolean setObjectConvert(int parameterIndex, Object JavaDoc x) throws SQLException JavaDoc
149     {
150         if (x instanceof BigDecimal JavaDoc) {
151             setBigDecimal(parameterIndex, (BigDecimal JavaDoc) x);
152             return true;
153         }
154         return false;
155     }
156 }
157
158
Popular Tags