{@inheritDoc}
@throw SQLFeatureNotSupportedException if this BLOB is empty
962963
public OutputStream setBinaryStream(final long pos) throws SQLException {
        synchronized (this) {
            if (this.underlying == null) {
                if (pos > 1) {
                    throw new SQLException("Invalid position: " + pos);
                } // end of if

                throw new SQLFeatureNotSupportedException("Cannot write to empty BLOB");
            } // end of if

            // ---

            return this.underlying.setBinaryStream(pos);
        } // end of sync
    }
433984
@Override
    public void setBlob(String parameterName, Blob x) throws SQLException
    {
        checkClosed();
        throw SQLError.noSupport();
    }
453325
@PostConstruct
	protected void initFeatures() throws LayerException {
		if (null == layerInfo) {
			return;
		}
		crs = geoService.getCrs2(layerInfo.getCrs());
		setFeatureSourceName(layerInfo.getFeatureInfo().getDataSourceName());
		try {
			if (null == super.getDataStore()) {
				Map<String, Object> params = new HashMap<String, Object>();
				if (null != url) {
					params.put(ShapefileDataStoreFactory.URLP.key, url);
				}
				if (null != dbtype) {
					params.put(JDBCDataStoreFactory.DBTYPE.key, dbtype);
				}
				if (null != parameters) {
					for (Parameter parameter : parameters) {
						params.put(parameter.getName(), parameter.getValue());
					}
				}
				if (null != dataSource) {
					params.put(JDBCDataStoreFactory.DATASOURCE.key, dataSource);
					// these are apparently required but not used
					params.put(JDBCDataStoreFactory.DATABASE.key, "some_database");
					params.put(JDBCDataStoreFactory.USER.key, "some_user");
					params.put(JDBCDataStoreFactory.PASSWD.key, "some_password");
					params.put(JDBCDataStoreFactory.HOST.key, "some host");
					params.put(JDBCDataStoreFactory.PORT.key, "0");
				}
				DataStore store = DataStoreFactory.create(params);
				super.setDataStore(store);
			}
			if (null == super.getDataStore()) {
				return;
			}
			this.featureModel = new GeoToolsFeatureModel(super.getDataStore(), layerInfo.getFeatureInfo()
					.getDataSourceName(), geoService.getSridFromCrs(layerInfo.getCrs()), converterService);
			featureModel.setLayerInfo(layerInfo);
			featureModelUsable = true;

		} catch (IOException ioe) {
			if (MAGIC_STRING_LIBRARY_MISSING.equals(ioe.getMessage())) {
				throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION, url);
			} else {
				featureModelUsable = false;
				log.warn("The layer could not be correctly initialized: " + getId(), ioe);
			}
		} catch (LayerException le) {
			featureModelUsable = false;
			log.warn("The layer could not be correctly initialized: " + getId(), le);
		} catch (RuntimeException e) {
			featureModelUsable = false;
			log.warn("The layer could not be correctly initialized: " + getId(), e);
		}
	}
1077546
@Override
    public boolean wasNull() throws SQLException {
        checkClosed();
        try {
            return table.wasNull();
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
50081
@Override
    public boolean getFeature(String featureId)
            throws SAXNotRecognizedException, SAXNotSupportedException {
        if ((FEATURE + "validation").equals(featureId)) {
            return false;
        }

        // external entities (both types) are optionally included
        if ((FEATURE + "external-general-entities").equals(featureId)) {
            return extGE;
        }
        if ((FEATURE + "external-parameter-entities").equals(featureId)) {
            return extPE;
        }

        // element/attribute names are as written in document; no mangling
        if ((FEATURE + "namespace-prefixes").equals(featureId)) {
            return xmlNames;
        }

        // report element/attribute namespaces?
        if ((FEATURE + "namespaces").equals(featureId)) {
            return namespaces;
        }

        // all PEs and GEs are reported
        if ((FEATURE + "lexical-handler/parameter-entities").equals(featureId)) {
            return true;
        }

        // default is true
        if ((FEATURE + "string-interning").equals(featureId)) {
            return stringInterning;
        }

        // EXTENSIONS 1.1

        // always returns isSpecified info
        if ((FEATURE + "use-attributes2").equals(featureId)) {
            return true;
        }

        // meaningful between startDocument/endDocument
        if ((FEATURE + "is-standalone").equals(featureId)) {
            if (parser == null) {
                throw new SAXNotSupportedException(featureId);
            }
            return parser.isStandalone();
        }

        // optionally don't absolutize URIs in declarations
        if ((FEATURE + "resolve-dtd-uris").equals(featureId)) {
            return resolveAll;
        }

        // optionally use resolver2 interface methods, if possible
        if ((FEATURE + "use-entity-resolver2").equals(featureId)) {
            return useResolver2;
        }

        if ("http://xml.org/sax/features/unicode-normalization-checking".equals(featureId)) {
            return checkNormalization;
        }

        throw new SAXNotRecognizedException(featureId);
    }
81881
@Override
  public ResultSet executeQuery(String sql) throws SQLException
  {
    raiseSQLExceptionIfStatementIsClosed();
    return executeQueryInternal(sql, null);
  }
614927
public static String getIfNotNull(String entityName, EntityColumn column, String contents, boolean empty) {
        StringBuilder sql = new StringBuilder();
        sql.append("<if test=\"");
        if (StringUtil.isNotEmpty(entityName)) {
            sql.append(entityName).append(".");
        }
        sql.append(column.getProperty()).append(" != null");
        if (empty && column.getJavaType().equals(String.class)) {
            sql.append(" and ");
            if (StringUtil.isNotEmpty(entityName)) {
                sql.append(entityName).append(".");
            }
            sql.append(column.getProperty()).append(" != '' ");
        }
        sql.append("\">");
        sql.append(contents);
        sql.append("</if>");
        return sql.toString();
    }
1368860
@FFDCIgnore(SQLException.class)
    private Boolean supportsUnicodeStaticCheck(DataSource ds) {
        Boolean res = null;
        try {
            Connection conn = ds.getConnection();
            String product = null;
            try {
                DatabaseMetaData dmd = conn.getMetaData();
                product = dmd.getDatabaseProductName();
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "supportsUnicodeStaticCheck : getDatabaseProductName = " + product);
                }
            } finally {
                conn.close();
            }
            for (Pattern supportedPattern : _unicodeSupportPlatform) {
                if (supportedPattern.matcher(product).matches()) {
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, "matched _unicodeSupportPlatform=" + supportedPattern.pattern());
                    }
                    return Boolean.TRUE;
                }
            }
            for (Pattern unsupported : _noUnicodeSupportPlatform) {
                if (unsupported.matcher(product).matches()) {
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, "matched _noUnicodeSupportPlatform=" + unsupported.pattern());
                    }
                    return Boolean.FALSE;
                }
            }
        } catch (SQLException e) {
            // Unexpected
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "Something went wrong in supportsUnicodeStaticCheck() -- ", e);
            }
        }
        return res;
    }
1177186
@Override
  public void setTransactionIsolation(int level) throws SQLException
  {
    logger.debug(
        "void setTransactionIsolation(int level), level = {}", level);
    raiseSQLExceptionIfConnectionIsClosed();
    if (level == Connection.TRANSACTION_NONE
        || level == Connection.TRANSACTION_READ_COMMITTED)
    {
      this.transactionIsolation = level;
    }
    else
    {
      throw new SQLFeatureNotSupportedException(
          "Transaction Isolation " + level + " not supported.",
          FEATURE_UNSUPPORTED.getSqlState(),
          FEATURE_UNSUPPORTED.getMessageCode());
    }
  }
520523
@Override
    public void setNClob(String parameterName, NClob value) throws SQLException
    {
        checkClosed();
        throw SQLError.noSupport();
    }
832633
public void updateRefs(boolean assetImport) throws SQLException, IOException {
        List<AssetRef> refs = getCurrentRefs();
        if (refs == null || refs.isEmpty())
            getOut().println("Skipping ASSET_REF table insert/update due to empty current assets");
        else {
            String select = "select name, ref from ASSET_REF where definition_id = ?";
            try (Connection conn = getDbConnection();
                    PreparedStatement stmt = conn.prepareStatement(select)) {
                for (AssetRef ref : refs) {
                    stmt.setLong(1, ref.getDefinitionId());
                    try (ResultSet rs = stmt.executeQuery()) {
                        // DO NOT update existing refs with newer commitID
                        // Doing so can obliterate previous commitID from ASSET_REF table
                        // which will prevent auto-import detection in cluster envs
                        if (!rs.next()) {
                            String insert = "insert into ASSET_REF (definition_id, name, ref) values (?, ?, ?)";
                            try (PreparedStatement insertStmt = conn.prepareStatement(insert)) {
                                insertStmt.setLong(1, ref.getDefinitionId());
                                insertStmt.setString(2, ref.getName());
                                insertStmt.setString(3, ref.getRef());
                                insertStmt.executeUpdate();
                                if (!conn.getAutoCommit()) conn.commit();
                            }
                        }
                    }
                }
                if (assetImport)
                    updateRefValue();
            }
        }
    }
365056
@Override
    public void setFeature(String featureId, boolean value)
            throws SAXNotRecognizedException, SAXNotSupportedException {
        boolean state;

        // Features with a defined value, we just change it if we can.
        state = getFeature(featureId);

        if (state == value) {
            return;
        }
        if (parser != null) {
            throw new SAXNotSupportedException("not while parsing");
        }

        if ((FEATURE + "namespace-prefixes").equals(featureId)) {
            // in this implementation, this only affects xmlns reporting
            xmlNames = value;
            // forcibly prevent illegal parser state
            if (!xmlNames) {
                namespaces = true;
            }
            return;
        }

        if ((FEATURE + "namespaces").equals(featureId)) {
            namespaces = value;
            // forcibly prevent illegal parser state
            if (!namespaces) {
                xmlNames = true;
            }
            return;
        }

        if ((FEATURE + "external-general-entities").equals(featureId)) {
            extGE = value;
            return;
        }
        if ((FEATURE + "external-parameter-entities").equals(featureId)) {
            extPE = value;
            return;
        }
        if ((FEATURE + "resolve-dtd-uris").equals(featureId)) {
            resolveAll = value;
            return;
        }

        if ((FEATURE + "use-entity-resolver2").equals(featureId)) {
            useResolver2 = value;
            return;
        }

        if ("http://xml.org/sax/features/unicode-normalization-checking".equals(featureId)) {
            checkNormalization = value;
            return;
        }

        throw new SAXNotRecognizedException(featureId);
    }
1020621
public static void createEmptyTable(Connection connection, String tableReference) throws SQLException {
        try (Statement statement = connection.createStatement()) {
            statement.execute("CREATE TABLE "+ tableReference+ " ()");
        }
    }
137146
public PreparedStatement prepareStatement(final String sql, 
                                              final int resultSetType, 
                                              final int resultSetConcurrency, 
                                              final int resultSetHoldability)
        throws SQLException {

        if (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
            throw new SQLFeatureNotSupportedException("Unsupported result set holdability");
        } // end of if

        return prepareStatement(sql, resultSetType, resultSetConcurrency);
    }
138372
@Override
    public void setBlob(int parameterIndex, Blob x) throws SQLException {
        internalStmt.setBlob(parameterIndex, x);
    }
822395
private void throwCannotInstanciateUnsupported(EJBBinding binding,
                                                   JavaColonNamespace jndiType,
                                                   String lookupName,
                                                   String messageId) throws NameNotFoundException {
        J2EEName j2eeName = getJ2EEName(binding);
        String jndiName = jndiType.toString() + "/" + lookupName;
        String msgTxt = Tr.formatMessage(tc, messageId,
                                         binding.interfaceName,
                                         j2eeName.getComponent(),
                                         j2eeName.getModule(),
                                         j2eeName.getApplication(),
                                         jndiName);
        throw (new NameNotFoundException(msgTxt));
    }
354620
public static <T> T getValueOfCertainColumnOfCertainRecord(String sql, Object... arg) {
        List<T> list = DBUtils.getValueOfCertainColumnOfAllRecord(sql, arg);
        if (list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }