001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/db/tags/sakai_2-4-1/db-api/api/src/java/org/sakaiproject/db/cover/SqlService.java $
003: * $Id: SqlService.java 22826 2007-03-17 18:59:47Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.db.cover;
021:
022: import org.sakaiproject.component.cover.ComponentManager;
023:
024: /**
025: * <p>
026: * SqlService is a static Cover for the {@link org.sakaiproject.db.api.SqlService SqlService}; see that interface for usage details.
027: * </p>
028: */
029: public class SqlService {
030: /**
031: * Access the component instance: special cover only method.
032: *
033: * @return the component instance.
034: */
035: public static org.sakaiproject.db.api.SqlService getInstance() {
036: if (ComponentManager.CACHE_COMPONENTS) {
037: if (m_instance == null)
038: m_instance = (org.sakaiproject.db.api.SqlService) ComponentManager
039: .get(org.sakaiproject.db.api.SqlService.class);
040: return m_instance;
041: } else {
042: return (org.sakaiproject.db.api.SqlService) ComponentManager
043: .get(org.sakaiproject.db.api.SqlService.class);
044: }
045: }
046:
047: private static org.sakaiproject.db.api.SqlService m_instance = null;
048:
049: public static java.sql.Connection borrowConnection()
050: throws java.sql.SQLException {
051: org.sakaiproject.db.api.SqlService service = getInstance();
052: if (service == null)
053: return null;
054:
055: return service.borrowConnection();
056: }
057:
058: public static void returnConnection(java.sql.Connection param0) {
059: org.sakaiproject.db.api.SqlService service = getInstance();
060: if (service == null)
061: return;
062:
063: service.returnConnection(param0);
064: }
065:
066: public static boolean transact(Runnable callback, String tag) {
067: org.sakaiproject.db.api.SqlService service = getInstance();
068: if (service == null)
069: return false;
070:
071: return service.transact(callback, tag);
072: }
073:
074: public static java.util.List dbRead(java.lang.String param0) {
075: org.sakaiproject.db.api.SqlService service = getInstance();
076: if (service == null)
077: return null;
078:
079: return service.dbRead(param0);
080: }
081:
082: public static java.util.List dbRead(java.lang.String param0,
083: java.lang.Object[] param1,
084: org.sakaiproject.db.api.SqlReader param2) {
085: org.sakaiproject.db.api.SqlService service = getInstance();
086: if (service == null)
087: return null;
088:
089: return service.dbRead(param0, param1, param2);
090: }
091:
092: public static java.util.List dbRead(java.sql.Connection param0,
093: java.lang.String param1, java.lang.Object[] param2,
094: org.sakaiproject.db.api.SqlReader param3) {
095: org.sakaiproject.db.api.SqlService service = getInstance();
096: if (service == null)
097: return null;
098:
099: return service.dbRead(param0, param1, param2, param3);
100: }
101:
102: public static void dbReadBinary(java.lang.String param0,
103: java.lang.Object[] param1, byte[] param2) {
104: org.sakaiproject.db.api.SqlService service = getInstance();
105: if (service == null)
106: return;
107:
108: service.dbReadBinary(param0, param1, param2);
109: }
110:
111: public static void dbReadBinary(java.sql.Connection param0,
112: java.lang.String param1, java.lang.Object[] param2,
113: byte[] param3) {
114: org.sakaiproject.db.api.SqlService service = getInstance();
115: if (service == null)
116: return;
117:
118: service.dbReadBinary(param0, param1, param2, param3);
119: }
120:
121: public static java.io.InputStream dbReadBinary(
122: java.lang.String param0, java.lang.Object[] param1,
123: boolean param2)
124: throws org.sakaiproject.exception.ServerOverloadException {
125: org.sakaiproject.db.api.SqlService service = getInstance();
126: if (service == null)
127: return null;
128:
129: return service.dbReadBinary(param0, param1, param2);
130: }
131:
132: public static boolean dbWrite(java.lang.String param0) {
133: org.sakaiproject.db.api.SqlService service = getInstance();
134: if (service == null)
135: return false;
136:
137: return service.dbWrite(param0);
138: }
139:
140: public static boolean dbWrite(java.lang.String param0,
141: java.lang.String param1) {
142: org.sakaiproject.db.api.SqlService service = getInstance();
143: if (service == null)
144: return false;
145:
146: return service.dbWrite(param0, param1);
147: }
148:
149: public static boolean dbWrite(java.lang.String param0,
150: java.lang.Object[] param1) {
151: org.sakaiproject.db.api.SqlService service = getInstance();
152: if (service == null)
153: return false;
154:
155: return service.dbWrite(param0, param1);
156: }
157:
158: public static boolean dbWrite(java.sql.Connection param0,
159: java.lang.String param1, java.lang.Object[] param2) {
160: org.sakaiproject.db.api.SqlService service = getInstance();
161: if (service == null)
162: return false;
163:
164: return service.dbWrite(param0, param1, param2);
165: }
166:
167: public static boolean dbWrite(java.lang.String param0,
168: java.lang.Object[] param1, java.lang.String param2) {
169: org.sakaiproject.db.api.SqlService service = getInstance();
170: if (service == null)
171: return false;
172:
173: return service.dbWrite(param0, param1, param2);
174: }
175:
176: public static boolean dbWriteBinary(java.lang.String param0,
177: java.lang.Object[] param1, byte[] param2, int param3,
178: int param4) {
179: org.sakaiproject.db.api.SqlService service = getInstance();
180: if (service == null)
181: return false;
182:
183: return service.dbWriteBinary(param0, param1, param2, param3,
184: param4);
185: }
186:
187: public static boolean dbWriteFailQuiet(java.sql.Connection param0,
188: java.lang.String param1, java.lang.Object[] param2) {
189: org.sakaiproject.db.api.SqlService service = getInstance();
190: if (service == null)
191: return false;
192:
193: return service.dbWriteFailQuiet(param0, param1, param2);
194: }
195:
196: public static void dbReadBlobAndUpdate(java.lang.String param0,
197: byte[] param1) {
198: org.sakaiproject.db.api.SqlService service = getInstance();
199: if (service == null)
200: return;
201:
202: service.dbReadBlobAndUpdate(param0, param1);
203: }
204:
205: public static java.sql.Connection dbReadLock(
206: java.lang.String param0, java.lang.StringBuffer param1) {
207: org.sakaiproject.db.api.SqlService service = getInstance();
208: if (service == null)
209: return null;
210:
211: return service.dbReadLock(param0, param1);
212: }
213:
214: public static void dbUpdateCommit(java.lang.String param0,
215: java.lang.Object[] param1, java.lang.String param2,
216: java.sql.Connection param3) {
217: org.sakaiproject.db.api.SqlService service = getInstance();
218: if (service == null)
219: return;
220:
221: service.dbUpdateCommit(param0, param1, param2, param3);
222: }
223:
224: public static void dbCancel(java.sql.Connection param0) {
225: org.sakaiproject.db.api.SqlService service = getInstance();
226: if (service == null)
227: return;
228:
229: service.dbCancel(param0);
230: }
231:
232: public static java.util.GregorianCalendar getCal() {
233: org.sakaiproject.db.api.SqlService service = getInstance();
234: if (service == null)
235: return null;
236:
237: return service.getCal();
238: }
239:
240: public static java.lang.String getVendor() {
241: org.sakaiproject.db.api.SqlService service = getInstance();
242: if (service == null)
243: return null;
244:
245: return service.getVendor();
246: }
247:
248: public static Long getNextSequence(String tableName,
249: java.sql.Connection conn) {
250: org.sakaiproject.db.api.SqlService service = getInstance();
251: if (service == null)
252: return null;
253:
254: return service.getNextSequence(tableName, conn);
255: }
256:
257: public static String getBooleanConstant(boolean value) {
258: org.sakaiproject.db.api.SqlService service = getInstance();
259: if (service == null)
260: return null;
261:
262: return service.getBooleanConstant(value);
263: }
264: }
|