1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ojb.broker.platforms;
18
19
20
21 import java.io.ByteArrayInputStream;
22 import java.io.InputStreamReader;
23 import java.io.Reader;
24 import java.io.StringReader;
25 import java.sql.PreparedStatement;
26 import java.sql.SQLException;
27 import java.sql.Types;
28
29 import org.apache.ojb.broker.query.LikeCriteria;
30
31
32
33
34
35
36
37 public class PlatformMckoiImpl extends PlatformDefaultImpl
38 {
39
40
41
42 public void setObjectForStatement(PreparedStatement statement, int index, Object value, int sqlType) throws SQLException
43 {
44 switch (sqlType)
45 {
46 case Types.BLOB :
47 case Types.LONGVARBINARY :
48 case Types.VARBINARY :
49 if (value instanceof byte[])
50 {
51 byte[] buf = (byte[])value;
52 ByteArrayInputStream inputStream = new ByteArrayInputStream(buf);
53 statement.setBinaryStream(index, inputStream, buf.length);
54
55 break;
56 }
57
58 case Types.CLOB :
59 Reader reader = null;
60 int length = 0;
61
62 if (value instanceof String)
63 {
64 reader = new StringReader((String)value);
65 length = (((String)value)).length();
66 }
67 else if (value instanceof char[])
68 {
69 String string = new String((char[])value);
70
71 reader = new StringReader(string);
72 length = string.length();
73 }
74 else if (value instanceof byte[])
75 {
76 ByteArrayInputStream inputStream = new ByteArrayInputStream((byte[])value);
77
78 reader = new InputStreamReader(inputStream);
79 }
80 statement.setCharacterStream(index, reader, length);
81 break;
82
83 default :
84 super.setObjectForStatement(statement, index, value, sqlType);
85
86 }
87 }
88
89
90
91
92 public String createSequenceQuery(String sequenceName)
93 {
94 return "create sequence " + sequenceName;
95 }
96
97
98
99
100 public String nextSequenceQuery(String sequenceName)
101 {
102 return "select nextval('" + sequenceName + "')";
103 }
104
105
106
107
108 public String dropSequenceQuery(String sequenceName)
109 {
110 return "drop sequence " + sequenceName;
111 }
112
113
114
115
116 public byte getJoinSyntaxType()
117 {
118 return SQL92_NOPAREN_JOIN_SYNTAX;
119 }
120
121
122
123
124 public boolean supportsPaging()
125 {
126
127 return false;
128 }
129
130
131
132
133 public String concatenate(String[] columns)
134 {
135 if (columns.length == 1)
136 {
137 return columns[0];
138 }
139
140 StringBuffer buf = new StringBuffer();
141
142 buf.append("concat(");
143 for (int idx = 0; idx < columns.length; idx++)
144 {
145 if (idx > 0)
146 {
147 buf.append(",");
148 }
149 buf.append(columns[idx]);
150 }
151 buf.append(")");
152
153 return buf.toString();
154 }
155
156
157
158
159 public String getEscapeClause(LikeCriteria criteria)
160 {
161
162
163 return "";
164 }
165 }