1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.jdbc4olap.jdbc;
24
25 import java.net.MalformedURLException;
26 import java.net.URL;
27 import java.sql.CallableStatement;
28 import java.sql.Connection;
29 import java.sql.DatabaseMetaData;
30 import java.sql.PreparedStatement;
31 import java.sql.ResultSet;
32 import java.sql.SQLException;
33 import java.sql.SQLWarning;
34 import java.sql.Savepoint;
35 import java.sql.Statement;
36 import java.util.HashMap;
37 import java.util.Map;
38 import java.util.Properties;
39
40 import org.jdbc4olap.xmla.XmlaConn;
41
42
43
44
45
46
47 class OlapConnection implements Connection {
48
49 private XmlaConn xmlaConn;
50 private String catalog;
51 private int holdability;
52 private boolean autocommit;
53 private Map<String,Class<?>> typeMap;
54
55 private final DatabaseMetaData metaData;
56
57
58
59
60
61
62 OlapConnection(final XmlaConn mockXmlaConn) {
63 xmlaConn = mockXmlaConn;
64 metaData = new OlapDatabaseMetaData(this);
65 }
66
67 OlapConnection(final String url, final Properties info) throws MalformedURLException, SQLException {
68 if (url == null || url.length() == 0) {
69 throw new MalformedURLException("Connection initialization error");
70 }
71 xmlaConn = new XmlaConn(new URL(url), info);
72 metaData = new OlapDatabaseMetaData(this);
73 holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
74 autocommit = true;
75 typeMap = new HashMap<String,Class<?>>();
76 }
77
78 XmlaConn getXmlaConn() {
79 return xmlaConn;
80 }
81
82 public void clearWarnings() throws SQLException {
83 }
84
85 public void close() throws SQLException {
86 xmlaConn = null;
87 }
88
89 public void commit() throws SQLException {
90 }
91
92 public Statement createStatement() throws SQLException {
93 return new OlapStatement(this);
94 }
95
96 public Statement createStatement(final int arg0, final int arg1) throws SQLException {
97 return new OlapStatement(this);
98 }
99
100 public Statement createStatement(final int arg0, final int arg1, final int arg2) throws SQLException {
101 return new OlapStatement(this);
102 }
103
104 public boolean getAutoCommit() throws SQLException {
105 return autocommit;
106 }
107
108 public String getCatalog() throws SQLException {
109 return catalog;
110 }
111
112 public int getHoldability() throws SQLException {
113 return holdability;
114 }
115
116 public DatabaseMetaData getMetaData() throws SQLException {
117 return metaData;
118 }
119
120 public int getTransactionIsolation() throws SQLException {
121 return Connection.TRANSACTION_NONE;
122 }
123
124 public Map<String,Class<?>> getTypeMap() throws SQLException {
125 return typeMap;
126 }
127
128 public SQLWarning getWarnings() throws SQLException {
129 return null;
130 }
131
132 public boolean isClosed() throws SQLException {
133 return xmlaConn == null;
134 }
135
136 public boolean isReadOnly() throws SQLException {
137 return true;
138 }
139
140 public String nativeSQL(final String arg0) throws SQLException {
141 return arg0;
142 }
143
144 public CallableStatement prepareCall(final String arg0) throws SQLException {
145 return null;
146 }
147
148 public CallableStatement prepareCall(final String arg0, final int arg1, final int arg2) throws SQLException {
149 return null;
150 }
151
152 public CallableStatement prepareCall(final String arg0, final int arg1, final int arg2, final int arg3) throws SQLException {
153 return null;
154 }
155
156 public PreparedStatement prepareStatement(final String arg0) throws SQLException {
157 return new OlapPreparedStatement(this, arg0);
158 }
159
160 public PreparedStatement prepareStatement(final String arg0, final int arg1) throws SQLException {
161 return new OlapPreparedStatement(this, arg0);
162 }
163
164 public PreparedStatement prepareStatement(final String arg0, final int[] arg1) throws SQLException {
165 return new OlapPreparedStatement(this, arg0);
166 }
167
168 public PreparedStatement prepareStatement(final String arg0, final String[] arg1) throws SQLException {
169 return new OlapPreparedStatement(this, arg0);
170 }
171
172 public PreparedStatement prepareStatement(final String arg0, final int arg1, final int arg2) throws SQLException {
173 return new OlapPreparedStatement(this, arg0);
174 }
175
176 public PreparedStatement prepareStatement(final String arg0, final int arg1, final int arg2, final int arg3) throws SQLException {
177 return new OlapPreparedStatement(this, arg0);
178 }
179
180 public void releaseSavepoint(final Savepoint arg0) throws SQLException {
181 }
182
183 public void rollback() throws SQLException {
184 }
185
186 public void rollback(final Savepoint arg0) throws SQLException {
187 }
188
189 public void setAutoCommit(final boolean arg0) throws SQLException {
190 autocommit = arg0;
191 }
192
193 public void setCatalog(final String arg0) throws SQLException {
194 catalog = arg0;
195
196
197 }
198
199 public void setHoldability(final int arg0) throws SQLException {
200 holdability = arg0;
201 }
202
203 public void setReadOnly(final boolean arg0) throws SQLException {
204 }
205
206 public Savepoint setSavepoint() throws SQLException {
207 return null;
208 }
209
210 public Savepoint setSavepoint(final String arg0) throws SQLException {
211 return null;
212 }
213
214 public void setTransactionIsolation(final int arg0) throws SQLException {
215 }
216
217 public void setTypeMap(final Map<String,Class<?>> arg0) throws SQLException {
218 typeMap = arg0;
219 }
220
221
222 }