Java SQL Table getShapeText(Connection conn, String tableName)

Here you can find the source of getShapeText(Connection conn, String tableName)

Description

get Shape Text

License

Apache License

Declaration

private static Map<Integer, byte[]> getShapeText(Connection conn, String tableName) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.*;
import java.util.HashMap;
import java.util.Map;

public class Main {
    private static Map<Integer, byte[]> getShapeText(Connection conn, String tableName) throws SQLException {
        Map<Integer, byte[]> shpText = new HashMap<>();
        int count = 0;
        Statement stmt = null;/*from  w ww .ja v a 2s .c o  m*/
        String query = "SELECT sde.st_asbinary(shape) as shp FROM " + tableName;

        try {
            stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(query);
            while (rs.next()) {
                count++;
                //String shp = rs.getString("shp");
                byte[] shp = rs.getBytes("shp");
                shpText.put(count, shp);
            }
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        } finally {
            if (stmt != null) {
                stmt.close();
            }
        }
        return shpText;
    }
}

Related

  1. getLastCreatedEntry(Connection conn, String tableName)
  2. getMetaDataMap(Statement statement, String tableOrViewName)
  3. getNextId(Connection con, String table, String identityFieldName)
  4. getRowCount(Statement stmt, String tableName)
  5. getSensorsList( final Connection jdbcConnection, String tableName)
  6. getTableFields(Connection con, String tableName)
  7. getTableList(Connection connection)
  8. getTableName(String sql)
  9. getTableNames(Connection conn)