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