KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > driver > ResultAndWarnings


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2006 Continuent, Inc.
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Initial developer(s): Gilles Rayrat.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.driver;
23
24 import java.sql.SQLWarning JavaDoc;
25 import java.util.List JavaDoc;
26
27 /**
28  * Holds the result of XXXExecuteUpdate() and XXXExecute() execution plus the
29  * possible SQL Warning chain that was generated by the database.<br>
30  * This holder contains a warning chain, that can be null, and either an update
31  * count (for XXXExecuteUpdate()) or a result list (for XXXExecute()), depending
32  * on the function call that generated the result.<br>
33  * <i>Note:</i> All methods of this class are package private, nobody but the
34  * driver itself should have access to it
35  *
36  * @author <a HREF="mailto:gilles.rayrat@continuent.com">Gilles Rayrat</a>
37  * @version 1.0
38  */

39 public class ResultAndWarnings
40 {
41   /** warning chain, null means no warning */
42   private SQLWarning JavaDoc statementWarnings = null;
43
44   private int updateCount = -1;
45   private List JavaDoc resultList = null;
46
47   /**
48    * Constructs a <code>ResultAndWarning</code> that will hold an updateCount
49    * and the given SQLWarnings.<br>
50    * This constructor will typically be called by XXXexecuteUpdate() functions
51    *
52    * @param uc the update count
53    * @param warns the warnings to set, can be null
54    * @see Connection#statementExecuteUpdate(org.continuent.sequoia.common.sql.Request)
55    * @see Connection#statementExecuteUpdateWithKeys(org.continuent.sequoia.common.sql.Request)
56    * @see Connection#callableStatementExecuteUpdate(org.continuent.sequoia.common.sql.Request)
57    */

58   ResultAndWarnings(int uc, SQLWarning JavaDoc warns)
59   {
60     statementWarnings = warns;
61     updateCount = uc;
62   }
63
64   /**
65    * Constructs a <code>ResultAndWarning</code> that will hold a resultList
66    * and the given SQLWarnings.<br>
67    * This constructor will typically be called by XXXexecute() functions
68    *
69    * @param reslist list of results
70    * @param warns the warnings to set, can be null
71    * @see Connection#statementExecute(org.continuent.sequoia.common.sql.RequestWithResultSetParameters)
72    * @see Connection#callableStatementExecute(org.continuent.sequoia.common.sql.RequestWithResultSetParameters)
73    */

74   ResultAndWarnings(List JavaDoc reslist, SQLWarning JavaDoc warns)
75   {
76     statementWarnings = warns;
77     resultList = reslist;
78   }
79
80   /**
81    * Gets the warning chain associated to the statement that generated the
82    * result
83    *
84    * @return a <code>SQLWarning</code> chain or null if no warnings
85    */

86   SQLWarning JavaDoc getStatementWarnings()
87   {
88     return statementWarnings;
89   }
90
91   /**
92    * Gets the updateCount. <i>Note:</i> if the held value is not an update
93    * count, then the returned value is unspecified
94    *
95    * @return the updateCount value
96    */

97   int getUpdateCount()
98   {
99     return updateCount;
100   }
101
102   /**
103    * Gets the ResultList. <i>Note:</i> if the held value is not an ResultList,
104    * then the returned value is unspecified
105    *
106    * @return the resultList value
107    */

108   List JavaDoc getResultList()
109   {
110     return resultList;
111   }
112 }
113
Popular Tags