Search in sources :

Example 1 with DatabaseParameterBuffer

use of org.firebirdsql.gds.DatabaseParameterBuffer in project jaybird by FirebirdSQL.

the class FBConnection method getEscapedParser.

/**
 * Returns the FBEscapedParser instance for this connection.
 *
 * @return Instance of FBEscapedParser
 */
protected FBEscapedParser getEscapedParser() {
    if (escapedParser == null) {
        DatabaseParameterBuffer dpb = getDatabaseParameterBuffer();
        EscapeParserMode mode = dpb.hasArgument(DatabaseParameterBufferExtension.USE_STANDARD_UDF) ? EscapeParserMode.USE_STANDARD_UDF : EscapeParserMode.USE_BUILT_IN;
        escapedParser = new FBEscapedParser(mode);
    }
    return escapedParser;
}
Also used : FBEscapedParser(org.firebirdsql.jdbc.escape.FBEscapedParser) EscapeParserMode(org.firebirdsql.jdbc.escape.FBEscapedParser.EscapeParserMode) DatabaseParameterBuffer(org.firebirdsql.gds.DatabaseParameterBuffer)

Example 2 with DatabaseParameterBuffer

use of org.firebirdsql.gds.DatabaseParameterBuffer in project jaybird by FirebirdSQL.

the class FBConnectionProperties method getDatabaseParameterBuffer.

/**
 * @deprecated TODO Usage of this method should be removed or revised as current use of default encoding is not correct.
 */
@Deprecated
public DatabaseParameterBuffer getDatabaseParameterBuffer() throws SQLException {
    // TODO Instance creation should be done through FbDatabase or database factory?
    DatabaseParameterBuffer dpb = new DatabaseParameterBufferImp(DatabaseParameterBufferImp.DpbMetaData.DPB_VERSION_1, EncodingFactory.getPlatformEncoding());
    for (Map.Entry<String, Object> entry : properties.entrySet()) {
        String propertyName = entry.getKey();
        Object value = entry.getValue();
        Integer dpbType = ParameterBufferHelper.getDpbKey(propertyName);
        if (dpbType == null)
            continue;
        if (value instanceof Boolean) {
            if ((Boolean) value)
                dpb.addArgument(dpbType);
        } else if (value instanceof Byte) {
            dpb.addArgument(dpbType, new byte[] { (Byte) value });
        } else if (value instanceof Integer) {
            dpb.addArgument(dpbType, (Integer) value);
        } else if (value instanceof String) {
            dpb.addArgument(dpbType, (String) value);
        } else if (value == null)
            dpb.addArgument(dpbType);
    }
    return dpb;
}
Also used : DatabaseParameterBufferImp(org.firebirdsql.gds.impl.DatabaseParameterBufferImp) DatabaseParameterBuffer(org.firebirdsql.gds.DatabaseParameterBuffer) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with DatabaseParameterBuffer

use of org.firebirdsql.gds.DatabaseParameterBuffer in project jaybird by FirebirdSQL.

the class FBStatement method nativeSQL.

protected String nativeSQL(String sql) throws SQLException {
    if (connection != null) {
        return connection.nativeSQL(sql);
    } else {
        DatabaseParameterBuffer dpb = gdsHelper.getDatabaseParameterBuffer();
        EscapeParserMode mode = dpb.hasArgument(DatabaseParameterBufferExtension.USE_STANDARD_UDF) ? EscapeParserMode.USE_STANDARD_UDF : EscapeParserMode.USE_BUILT_IN;
        return new FBEscapedParser(mode).parse(sql);
    }
}
Also used : FBEscapedParser(org.firebirdsql.jdbc.escape.FBEscapedParser) EscapeParserMode(org.firebirdsql.jdbc.escape.FBEscapedParser.EscapeParserMode) DatabaseParameterBuffer(org.firebirdsql.gds.DatabaseParameterBuffer)

Example 4 with DatabaseParameterBuffer

use of org.firebirdsql.gds.DatabaseParameterBuffer in project jaybird by FirebirdSQL.

the class V12ParameterConverter method createDatabaseParameterBuffer.

protected DatabaseParameterBuffer createDatabaseParameterBuffer(WireDatabaseConnection connection) {
    final Encoding stringEncoding = connection.getEncodingFactory().getEncodingForFirebirdName("UTF8");
    DatabaseParameterBuffer dpb = new DatabaseParameterBufferImp(DatabaseParameterBufferImp.DpbMetaData.DPB_VERSION_1, stringEncoding);
    dpb.addArgument(DpbItems.isc_dpb_utf8_filename);
    return dpb;
}
Also used : DatabaseParameterBufferImp(org.firebirdsql.gds.impl.DatabaseParameterBufferImp) Encoding(org.firebirdsql.encodings.Encoding) DatabaseParameterBuffer(org.firebirdsql.gds.DatabaseParameterBuffer)

Aggregations

DatabaseParameterBuffer (org.firebirdsql.gds.DatabaseParameterBuffer)4 DatabaseParameterBufferImp (org.firebirdsql.gds.impl.DatabaseParameterBufferImp)2 FBEscapedParser (org.firebirdsql.jdbc.escape.FBEscapedParser)2 EscapeParserMode (org.firebirdsql.jdbc.escape.FBEscapedParser.EscapeParserMode)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Encoding (org.firebirdsql.encodings.Encoding)1