KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > impl > jdbcjobstore > CloudscapeDelegate


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 /*
19  * Previously Copyright (c) 2001-2004 James House
20  */

21
22 package org.quartz.impl.jdbcjobstore;
23
24 import java.io.ByteArrayInputStream JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.ObjectInputStream JavaDoc;
27 import java.sql.ResultSet JavaDoc;
28 import java.sql.SQLException JavaDoc;
29
30 import org.apache.commons.logging.Log;
31
32 /**
33  * <p>
34  * This is a driver delegate for the Cloudscape database, not surprisingly,
35  * it is known to work with Derby as well.
36  * </p>
37  *
38  * @author James House
39  * @author Sridhar Jawaharlal, Srinivas Venkatarangaiah
40  */

41 public class CloudscapeDelegate extends StdJDBCDelegate {
42     /**
43      * <p>
44      * Create new CloudscapeDelegate instance.
45      * </p>
46      *
47      * @param log
48      * the logger to use during execution
49      * @param tablePrefix
50      * the prefix of all table names
51      */

52     public CloudscapeDelegate(Log log, String JavaDoc tablePrefix, String JavaDoc instanceId) {
53         super(log, tablePrefix, instanceId);
54     }
55
56     /**
57      * <p>
58      * Create new CloudscapeDelegate instance.
59      * </p>
60      *
61      * @param log
62      * the logger to use during execution
63      * @param tablePrefix
64      * the prefix of all table names
65      * @param useProperties
66      * useProperties flag
67      */

68     public CloudscapeDelegate(Log log, String JavaDoc tablePrefix, String JavaDoc instanceId,
69             Boolean JavaDoc useProperties) {
70         super(log, tablePrefix, instanceId, useProperties);
71     }
72
73     //---------------------------------------------------------------------------
74
// protected methods that can be overridden by subclasses
75
//---------------------------------------------------------------------------
76

77     /**
78      * <p>
79      * This method should be overridden by any delegate subclasses that need
80      * special handling for BLOBs. The default implementation uses standard
81      * JDBC <code>java.sql.Blob</code> operations.
82      * </p>
83      *
84      * @param rs
85      * the result set, already queued to the correct row
86      * @param colName
87      * the column name for the BLOB
88      * @return the deserialized Object from the ResultSet BLOB
89      * @throws ClassNotFoundException
90      * if a class found during deserialization cannot be found
91      * @throws IOException
92      * if deserialization causes an error
93      */

94     protected Object JavaDoc getObjectFromBlob(ResultSet JavaDoc rs, String JavaDoc colName)
95         throws ClassNotFoundException JavaDoc, IOException JavaDoc, SQLException JavaDoc {
96         Object JavaDoc obj = null;
97
98         byte[] inputBytes = rs.getBytes(colName);
99
100         if (null != inputBytes) {
101             ByteArrayInputStream JavaDoc bais = new
102             ByteArrayInputStream JavaDoc(inputBytes);
103
104             ObjectInputStream JavaDoc in = new ObjectInputStream JavaDoc(bais);
105             try {
106                 obj = in.readObject();
107             } finally {
108                 in.close();
109             }
110         }
111
112         return obj;
113     }
114 }
115
116 // EOF
117
Popular Tags