KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > dba > frontbase > FrontBaseCharType


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. 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,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.dba.frontbase;
21
22 import java.sql.Clob JavaDoc;
23 import java.sql.PreparedStatement JavaDoc;
24 import java.sql.Types JavaDoc;
25
26 import org.apache.cayenne.access.types.CharType;
27 import org.apache.cayenne.util.MemoryClob;
28
29 /**
30  * A char type that uses a real clob for insertion.
31  *
32  * @since 1.2
33  * @author Andrus Adamchik
34  */

35 // actually this is the way CLOBs must be handled by default, but there are still some
36
// issues with other adapters, so we can't move this to a superclass yet.
37
class FrontBaseCharType extends CharType {
38
39     FrontBaseCharType() {
40         super(false, true);
41     }
42
43     public void setJdbcObject(
44             PreparedStatement JavaDoc st,
45             Object JavaDoc val,
46             int pos,
47             int type,
48             int precision) throws Exception JavaDoc {
49
50         if (type == Types.CLOB) {
51             st.setClob(pos, writeClob((String JavaDoc) val));
52         }
53         else {
54             super.setJdbcObject(st, val, pos, type, precision);
55         }
56     }
57
58     Clob JavaDoc writeClob(String JavaDoc string) {
59         return string != null ? new MemoryClob(string) : null;
60     }
61 }
62
Popular Tags