svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.db / org.gvsig.fmap.dal.db.h2 / src / main / java / org / gvsig / fmap / dal / store / h2 / operations / H2SpatialListTablesOperation.java @ 44644
History | View | Annotate | Download (1.77 KB)
1 | 43377 | jjdelcerro | package org.gvsig.fmap.dal.store.h2.operations; |
---|---|---|---|
2 | 43020 | jjdelcerro | |
3 | import java.sql.Connection; |
||
4 | import java.sql.ResultSet; |
||
5 | import java.sql.SQLException; |
||
6 | import java.util.ArrayList; |
||
7 | import java.util.List; |
||
8 | import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
||
9 | import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
||
10 | import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
||
11 | 43377 | jjdelcerro | import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ListTablesOperation; |
12 | 43020 | jjdelcerro | |
13 | 43377 | jjdelcerro | public class H2SpatialListTablesOperation extends ListTablesOperation { |
14 | 43020 | jjdelcerro | |
15 | 43377 | jjdelcerro | public H2SpatialListTablesOperation(JDBCHelper helper, int mode, JDBCStoreParameters baseParameters, boolean informationTables) { |
16 | super(helper, mode, baseParameters, informationTables);
|
||
17 | 43020 | jjdelcerro | } |
18 | |||
19 | 43377 | jjdelcerro | @Override
|
20 | 43020 | jjdelcerro | public List<JDBCStoreParameters> listTables( |
21 | Connection conn,
|
||
22 | int mode,
|
||
23 | JDBCStoreParameters baseParameters, |
||
24 | boolean informationTables
|
||
25 | ) { |
||
26 | ResultSet rs = null; |
||
27 | List<JDBCStoreParameters> tables = new ArrayList<>(); |
||
28 | |||
29 | try {
|
||
30 | 43377 | jjdelcerro | String sql = "SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where table_type in ('TABLE','VIEW','EXTERNAL')"; |
31 | rs = conn.createStatement().executeQuery(sql); |
||
32 | 43020 | jjdelcerro | while (rs.next()) {
|
33 | JDBCStoreParameters params = baseParameters.getCopy(); |
||
34 | 43377 | jjdelcerro | params.setCatalog(rs.getString("TABLE_CATALOG"));
|
35 | params.setSchema(rs.getString("TABLE_SCHEMA"));
|
||
36 | params.setTable(rs.getString("TABLE_NAME"));
|
||
37 | 43020 | jjdelcerro | tables.add(params); |
38 | } |
||
39 | return tables;
|
||
40 | |||
41 | } catch (SQLException ex) { |
||
42 | throw new RuntimeException("Can't fetch tables information",ex); |
||
43 | |||
44 | } finally {
|
||
45 | JDBCUtils.closeQuietly(rs); |
||
46 | } |
||
47 | |||
48 | } |
||
49 | } |