public static int getSRID(Connection connection, String catalogName, String schemaName, String tableName, String columnName,String constraint) {
        try {
            Statement st = connection.createStatement();
            // Merge column constraint and table constraint
            constraint+=fetchConstraint(connection, catalogName, schemaName,tableName);
            if(constraint.toUpperCase().contains(SRID_FUNC)) {
                // Check constraint
                // Extract column and SRID constraint value
                // constraint = ".. ST_SRID(the_geom) = 27572 .."
                int srid = getSRIDFromConstraint(constraint, columnName);
                if(srid > 0) {
                    return srid;
                }
            }
            try ( // Fetch the first geometry to find a stored SRID
                    ResultSet rs = st.executeQuery(String.format("select ST_SRID(%s) from %s LIMIT 1;",
                            StringUtils.quoteJavaString(columnName.toUpperCase()),new TableLocation(catalogName, schemaName, tableName)))) {
                if(rs.next()) {
                    int srid = rs.getInt(1);
                    if(srid > 0) {
                        return srid;
                    }
                }
            }
            // Unable to find a valid SRID
            return 0;
        } catch (SQLException ex) {
            return 0;
        }
    }
public static int getSRID ( Connection connection , String catalogName , String schemaName , String tableName , String columnName , String constraint ) { try { Statement st = connection . createStatement ( ) ; constraint += fetchConstraint ( connection , catalogName , schemaName , tableName ) ; if ( constraint . toUpperCase ( ) . contains ( SRID_FUNC ) ) { int srid = getSRIDFromConstraint ( constraint , columnName ) ; if ( srid > 0 ) { return srid ; } } try ( ResultSet rs = st . executeQuery ( String . format ( "select ST_SRID(%s) from %s LIMIT 1;" , StringUtils . quoteJavaString ( columnName . toUpperCase ( ) ) , new TableLocation ( catalogName , schemaName , tableName ) ) ) ) { if ( rs . next ( ) ) { int srid = rs . getInt ( 1 ) ; if ( srid > 0 ) { return srid ; } } } return 0 ; } catch ( SQLException ex ) { return 0 ; } }
@param connection Active connection
@param tableName Target table name
@param columnName Spatial field name
@param constraint Column constraint
@return The column SRID from constraints and data.