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.mdb / src / main / java / org / gvsig / fmap / dal / store / mdb / operations / MDBListTablesOperation.java @ 44954
History | View | Annotate | Download (1.73 KB)
1 | 44916 | omartinez | package org.gvsig.fmap.dal.store.mdb.operations; |
---|---|---|---|
2 | |||
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 | import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ListTablesOperation; |
||
12 | |||
13 | public class MDBListTablesOperation extends ListTablesOperation { |
||
14 | |||
15 | public MDBListTablesOperation(JDBCHelper helper, int mode, JDBCStoreParameters baseParameters, boolean informationTables) { |
||
16 | super(helper, mode, baseParameters, informationTables);
|
||
17 | } |
||
18 | |||
19 | |||
20 | @Override
|
||
21 | public List<JDBCStoreParameters> listTables( |
||
22 | Connection conn,
|
||
23 | int mode,
|
||
24 | JDBCStoreParameters baseParameters, |
||
25 | boolean informationTables
|
||
26 | ) { |
||
27 | ResultSet rs = null; |
||
28 | List<JDBCStoreParameters> tables = new ArrayList<>(); |
||
29 | |||
30 | try {
|
||
31 | 44954 | omartinez | String sql = "SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES"; |
32 | 44916 | omartinez | rs = conn.createStatement().executeQuery(sql); |
33 | while (rs.next()) {
|
||
34 | JDBCStoreParameters params = baseParameters.getCopy(); |
||
35 | params.setCatalog(rs.getString("TABLE_CATALOG"));
|
||
36 | params.setSchema(rs.getString("TABLE_SCHEMA"));
|
||
37 | params.setTable(rs.getString("TABLE_NAME"));
|
||
38 | tables.add(params); |
||
39 | } |
||
40 | return tables;
|
||
41 | |||
42 | } catch (SQLException ex) { |
||
43 | throw new RuntimeException("Can't fetch tables information",ex); |
||
44 | |||
45 | } finally {
|
||
46 | JDBCUtils.closeQuietly(rs); |
||
47 | } |
||
48 | |||
49 | } |
||
50 | } |