Revision 29977 trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/engine/data/db/JDBCSupport.java
JDBCSupport.java | ||
---|---|---|
22 | 22 |
public class JDBCSupport implements ReadAccess { |
23 | 23 |
private ResultSet resultSet; |
24 | 24 |
private int rowCount = -1; |
25 |
private Connection conn=null; |
|
26 |
private String sql=null; |
|
25 | 27 |
|
26 | 28 |
/** |
27 | 29 |
* Creates a new JDBCSupport object. |
28 | 30 |
* |
29 | 31 |
* @param r ResultSet that will be used to return the methods values |
30 | 32 |
*/ |
31 |
JDBCSupport(ResultSet r) { |
|
32 |
resultSet = r; |
|
33 |
JDBCSupport(ResultSet r, Connection con,String sql) { |
|
34 |
this.conn=con; |
|
35 |
this.sql=sql; |
|
36 |
resultSet = r; |
|
33 | 37 |
} |
34 | 38 |
|
35 | 39 |
/** |
... | ... | |
167 | 171 |
*/ |
168 | 172 |
public int getFieldCount() throws ReadDriverException { |
169 | 173 |
try { |
170 |
return resultSet.getMetaData().getColumnCount();
|
|
174 |
return resultSet.getMetaData().getColumnCount();
|
|
171 | 175 |
} catch (SQLException e) { |
172 |
throw new ReadDriverException("JDBC",e); |
|
176 |
try { |
|
177 |
newJDBCSupport(conn, sql); |
|
178 |
return resultSet.getMetaData().getColumnCount(); |
|
179 |
} catch (SQLException e1) { |
|
180 |
throw new ReadDriverException("JDBC",e); |
|
181 |
} |
|
173 | 182 |
} |
174 | 183 |
} |
175 | 184 |
|
... | ... | |
180 | 189 |
try { |
181 | 190 |
return resultSet.getMetaData().getColumnName(fieldId + 1); |
182 | 191 |
} catch (SQLException e) { |
183 |
throw new ReadDriverException("JDBC",e); |
|
192 |
try { |
|
193 |
newJDBCSupport(conn, sql); |
|
194 |
return resultSet.getMetaData().getColumnName(fieldId + 1); |
|
195 |
} catch (SQLException e1) { |
|
196 |
throw new ReadDriverException("JDBC",e); |
|
197 |
} |
|
184 | 198 |
} |
185 | 199 |
} |
186 | 200 |
|
... | ... | |
207 | 221 |
try { |
208 | 222 |
return resultSet.getMetaData().getColumnType(i + 1); |
209 | 223 |
} catch (SQLException e) { |
210 |
throw new ReadDriverException("JDBC",e); |
|
224 |
try { |
|
225 |
newJDBCSupport(conn, sql); |
|
226 |
return resultSet.getMetaData().getColumnType(i + 1); |
|
227 |
} catch (SQLException e1) { |
|
228 |
throw new ReadDriverException("JDBC",e); |
|
229 |
} |
|
211 | 230 |
} |
212 | 231 |
} |
213 | 232 |
|
... | ... | |
237 | 256 |
ResultSet.CONCUR_READ_ONLY); |
238 | 257 |
ResultSet res = st.executeQuery(sql); |
239 | 258 |
|
240 |
return new JDBCSupport(res); |
|
259 |
return new JDBCSupport(res, con, sql);
|
|
241 | 260 |
} |
242 | 261 |
|
243 | 262 |
/** |
... | ... | |
267 | 286 |
try { |
268 | 287 |
width = resultSet.getMetaData().getColumnDisplaySize(i + 1); |
269 | 288 |
} catch (SQLException e) { |
270 |
throw new ReadDriverException("JDBC",e); |
|
289 |
try { |
|
290 |
newJDBCSupport(conn, sql); |
|
291 |
width = resultSet.getMetaData().getColumnDisplaySize(i + 1); |
|
292 |
} catch (SQLException e1) { |
|
293 |
throw new ReadDriverException("JDBC",e); |
|
294 |
} |
|
271 | 295 |
} |
272 | 296 |
if (width < 0) return 255; |
273 | 297 |
return width; |
Also available in: Unified diff