KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > platform > database > AttunityPlatform


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.platform.database;
23
24 import java.util.*;
25 import oracle.toplink.essentials.expressions.*;
26 import oracle.toplink.essentials.internal.databaseaccess.*;
27
28 /**
29  * TopLink Platform class which works with Attunity's Connect JDBC driver.
30  */

31 public class AttunityPlatform extends oracle.toplink.essentials.platform.database.DatabasePlatform {
32     public AttunityPlatform() {
33         // For TEXT and IMAGE fields, streams must be used for binding
34
usesStreamsForBinding = true;
35         // Autocomit did not work as expected when this class was written.
36
supportsAutoCommit = false;
37     }
38
39     /**
40      * INTERNAL:
41      * Create a table which can translate between java types and Attunity Connect data types.
42      */

43     protected Hashtable buildFieldTypes() {
44         Hashtable fieldTypeMapping;
45
46         fieldTypeMapping = new Hashtable();
47         fieldTypeMapping.put(Boolean JavaDoc.class, new FieldTypeDefinition("TINYINT", false));
48
49         fieldTypeMapping.put(Integer JavaDoc.class, new FieldTypeDefinition("NUMERIC", 10));
50         fieldTypeMapping.put(Long JavaDoc.class, new FieldTypeDefinition("NUMERIC", 19));
51         fieldTypeMapping.put(Float JavaDoc.class, new FieldTypeDefinition("NUMERIC", 19, 4));
52         fieldTypeMapping.put(Double JavaDoc.class, new FieldTypeDefinition("NUMERIC", 19, 4));
53         fieldTypeMapping.put(Short JavaDoc.class, new FieldTypeDefinition("NUMERIC", 5));
54         fieldTypeMapping.put(Byte JavaDoc.class, new FieldTypeDefinition("NUMERIC", 3));
55         fieldTypeMapping.put(java.math.BigInteger JavaDoc.class, new FieldTypeDefinition("NUMERIC", 38));
56         fieldTypeMapping.put(java.math.BigDecimal JavaDoc.class, new FieldTypeDefinition("DOUBLE", false));
57         fieldTypeMapping.put(Number JavaDoc.class, new FieldTypeDefinition("DOUBLE", false));
58
59         fieldTypeMapping.put(String JavaDoc.class, new FieldTypeDefinition("VARCHAR", 255));
60         fieldTypeMapping.put(Character JavaDoc.class, new FieldTypeDefinition("CHAR", 1));
61
62         fieldTypeMapping.put(Byte JavaDoc[].class, new FieldTypeDefinition("IMAGE", false));
63         fieldTypeMapping.put(Character JavaDoc[].class, new FieldTypeDefinition("TEXT", false));
64         fieldTypeMapping.put(byte[].class, new FieldTypeDefinition("IMAGE", false));
65         fieldTypeMapping.put(char[].class, new FieldTypeDefinition("TEXT", false));
66         fieldTypeMapping.put(java.sql.Blob JavaDoc.class, new FieldTypeDefinition("IMAGE", false));
67         fieldTypeMapping.put(java.sql.Clob JavaDoc.class, new FieldTypeDefinition("TEXT", false));
68         
69         fieldTypeMapping.put(java.sql.Date JavaDoc.class, new FieldTypeDefinition("DATE", false));
70         fieldTypeMapping.put(java.sql.Time JavaDoc.class, new FieldTypeDefinition("TIME", false));
71         fieldTypeMapping.put(java.sql.Timestamp JavaDoc.class, new FieldTypeDefinition("TIMESTAMP", false));
72
73         return fieldTypeMapping;
74     }
75
76     /**
77      * INTERNAL:
78      * Initialize any platform-specific operators.
79      */

80     protected void initializePlatformOperators() {
81         super.initializePlatformOperators();
82         addOperator(ExpressionOperator.simpleTwoArgumentFunction(ExpressionOperator.Concat, "CONCAT"));
83     }
84
85     public boolean isAttunity() {
86         return true;
87     }
88
89     /**
90      * INTERNAL:
91      * Attunity Connect does not support specifying the primary key in the create table syntax.
92      * @return boolean false
93      */

94     public boolean supportsPrimaryKeyConstraint() {
95         return false;
96     }
97
98     /**
99      * INTERNAL:
100      * Attunity Connect does not support creating foreign key constraints with the ALTER TABLE syntax.
101      * @return boolean false.
102      */

103     public boolean supportsForeignKeyConstraints() {
104         return false;
105     }
106 }
107
Popular Tags