List of utility methods to do SQL Table
List | getSensorsList(final Connection jdbcConnection, String tableName) get Sensors List final List<String> sensors = new ArrayList<String>(); ResultSet rs = null; Statement stmt = null; try { stmt = jdbcConnection.createStatement(); String totalSensors = MessageFormat.format("SELECT DISTINCT(sensor) FROM {0} {1}", tableName, PREDICATE); rs = stmt.executeQuery(totalSensors); ... |
Map | getShapeText(Connection conn, String tableName) get Shape Text Map<Integer, byte[]> shpText = new HashMap<>(); int count = 0; Statement stmt = null; String query = "SELECT sde.st_asbinary(shape) as shp FROM " + tableName; try { stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); while (rs.next()) { ... |
List | getTableFields(Connection con, String tableName) get Table Fields List<String> tableList = new ArrayList<String>(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from " + tableName + " where 1=0"); try { ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); for (int i = 1; i <= columnCount; i++) { tableList.add(tableName + "." + rsmd.getColumnName(i)); ... |
ArrayList | getTableList(Connection connection) get Table List String request = "SELECT * FROM sqlite_master;"; Statement stmt = connection.createStatement(); ResultSet results = stmt.executeQuery(request); ResultSetMetaData resultsMtdt = results.getMetaData(); ArrayList<String> tables = new ArrayList<>(); while (results.next()) { Object obj = results.getObject(1); if (obj != null && obj instanceof String) { ... |
String | getTableName(String sql) get Table Name String tableName = ""; int pos = sql.indexOf(FROM_KEY); if (pos >= 0) { String tab = sql.substring(pos + FROM_KEY.length(), sql.length()); int pp = tab.indexOf(' '); if (pp >= 0) { tableName = tab.substring(0, pp); } else { ... |
String[] | getTableNames(Connection conn) get Table Names List<String> lTableName = new ArrayList<String>(); ResultSet rsTable = conn.getMetaData().getTables("", "", "", new String[] { "TABLE" }); while (rsTable.next()) { lTableName.add(rsTable.getString(3)); return lTableName.toArray(new String[0]); |
List | getTableNames(Connection conn) get Table Names DatabaseMetaData dbmd = conn.getMetaData(); String[] types = new String[] { "TABLE", "VIEW" }; ResultSet rs = dbmd.getTables(null, null, null, types); List tables = null; while (rs.next()) { String tableName = rs.getString("TABLE_NAME"); if (tables == null) { tables = new ArrayList(); ... |
List | getTables(Connection conn) Get a list of tables in the database. return getTables(conn, DEFAULT_TABLE_TYPES);
|
ResultSet | getTables(Connection connection) get Tables return connection.getMetaData().getTables(null, null, "%", new String[] { "TABLE" }); |
String[] | getTables(Connection connection) get Tables DatabaseMetaData metaData = connection.getMetaData(); String[] types = { "TABLE" }; ResultSet rs = metaData.getTables(null, null, "%", types); List<String> tables = new ArrayList<String>(); while (rs.next()) { tables.add(rs.getString("TABLE_NAME")); String[] names = new String[tables.size()]; ... |