Class JdbcUtil
java.lang.Object
org.frankframework.util.JdbcUtil
Database-oriented utility functions.
- Since:
- 4.1
- Author:
- Gerrit van Brakel
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyParameters(@NonNull IDbmsSupport dbmsSupport, @NonNull PreparedStatement statement, @NonNull ParameterValueList parameters) static voidapplyParameters(@NonNull IDbmsSupport dbmsSupport, @NonNull PreparedStatement statement, @Nullable ParameterList parameters, Message message, PipeLineSession session) static voidclose(@Nullable Connection connection) static voidfullClose(@Nullable Connection connection, @Nullable ResultSet rs) static voidfullClose(@Nullable Connection connection, @Nullable Statement statement) Note: Depending on the connect pool used (for example with Tomcat 7) the connection retrieved from the statement will be the direct connection instead of the proxied connection.static @Nullable StringgetBlobAsString(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int column, String charset, boolean blobIsCompressed, boolean blobSmartGet, boolean encodeBlobBase64) static StringgetBlobAsString(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, String column, String charset, boolean blobIsCompressed, boolean blobSmartGet, boolean encodeBlobBase64) static @Nullable InputStreamgetBlobInputStream(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int column, boolean blobIsCompressed) static @Nullable InputStreamgetBlobInputStream(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, String column, boolean blobIsCompressed) static OutputStreamgetBlobOutputStream(@NonNull IDbmsSupport dbmsSupport, @NonNull Object blobUpdateHandle, @NonNull ResultSet rs, int columnIndex, boolean compressBlob) static ReadergetBlobReader(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int column, @Nullable String charset, boolean blobIsCompressed) static StringgetClobAsString(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int columnIndex, boolean xmlEncode) static @Nullable StringgetValue(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int colNum, @NonNull ResultSetMetaData rsmeta, @Nullable String blobCharset, boolean decompressBlobs, String nullValue, boolean trimSpaces, boolean getBlobSmart, boolean encodeBlobBase64) Deprecated.static @NonNull MessagegetValueAsMessage(IDbmsSupport dbmsSupport, ResultSet rs, int colNum, ResultSetMetaData rsmeta, String blobCharset, boolean decompressBlobs) static @NonNull MessagegetValueAsMessage(IDbmsSupport dbmsSupport, ResultSet rs, int colNum, ResultSetMetaData rsmeta, String blobCharset, boolean decompressBlobs, boolean trimSpaces, boolean blobSmartGet, boolean blobEncodeBase64) static booleanisQueryResultEmpty(@NonNull Connection connection, @NonNull String query) static SQLTypemapParameterTypeToSqlType(@NonNull IDbmsSupport dbmsSupport, @NonNull ParameterType parameterType) static voidsetParameter(@NonNull PreparedStatement statement, int parameterIndex, @Nullable String value, boolean parameterTypeMatchRequired, @Nullable ParameterMetaData parameterMetaData) Set a parameter in a prepared statement.static voidsetParameter(PreparedStatement statement, int parameterIndex, String value, boolean parameterTypeMatchRequired) Set a parameter in a prepared statement.static voidstreamBlob(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int columnIndex, @Nullable String charset, boolean blobIsCompressed, Base64Pipe.Direction blobBase64Direction, MessageBuilder msgBuilder) static voidstreamClob(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int column, @NonNull MessageBuilder target) static @Nullable StringwarningsToString(@Nullable SQLWarning warnings) Deprecated.static voidwarningsToXml(@Nullable SQLWarning warnings, @NonNull XmlBuilder parent) Deprecated.static @Nullable XmlBuilderwarningsToXmlBuilder(@Nullable SQLWarning warnings) Deprecated.
-
Field Details
-
DATEFORMAT_DATE_TIME_FORMATTER
-
TIMESTAMP_DATE_TIME_FORMATTER
-
-
Method Details
-
warningsToString
Deprecated. -
warningsToXml
@Deprecated public static void warningsToXml(@Nullable SQLWarning warnings, @NonNull XmlBuilder parent) Deprecated. -
warningsToXmlBuilder
Deprecated. -
getValueAsMessage
public static @NonNull Message getValueAsMessage(IDbmsSupport dbmsSupport, ResultSet rs, int colNum, ResultSetMetaData rsmeta, String blobCharset, boolean decompressBlobs) throws SQLException, IOException - Throws:
SQLExceptionIOException
-
getValueAsMessage
public static @NonNull Message getValueAsMessage(IDbmsSupport dbmsSupport, ResultSet rs, int colNum, ResultSetMetaData rsmeta, String blobCharset, boolean decompressBlobs, boolean trimSpaces, boolean blobSmartGet, boolean blobEncodeBase64) throws SQLException, IOException - Throws:
SQLExceptionIOException
-
getValue
@Deprecated(since="10.3") public static @Nullable String getValue(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int colNum, @NonNull ResultSetMetaData rsmeta, @Nullable String blobCharset, boolean decompressBlobs, String nullValue, boolean trimSpaces, boolean getBlobSmart, boolean encodeBlobBase64) throws IOException, SQLException Deprecated.Where possible prefer to use the new methodgetValueAsMessage(IDbmsSupport, ResultSet, int, ResultSetMetaData, String, boolean)because it is more flexible, and the result can always still be turned into a String value withMessage.asString(). If flags missing from the old method are needed on the new method, they can be added as needed.Get value of column-nr from record-set current record and return it as String.- Throws:
IOExceptionSQLException
-
getBlobInputStream
public static @Nullable InputStream getBlobInputStream(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int column, boolean blobIsCompressed) throws SQLException, JdbcException - Throws:
SQLExceptionJdbcException
-
getBlobInputStream
public static @Nullable InputStream getBlobInputStream(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, String column, boolean blobIsCompressed) throws SQLException, JdbcException - Throws:
SQLExceptionJdbcException
-
getBlobReader
public static Reader getBlobReader(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int column, @Nullable String charset, boolean blobIsCompressed) throws IOException, JdbcException, SQLException - Throws:
IOExceptionJdbcExceptionSQLException
-
streamBlob
public static void streamBlob(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int columnIndex, @Nullable String charset, boolean blobIsCompressed, Base64Pipe.Direction blobBase64Direction, MessageBuilder msgBuilder) throws JdbcException, SQLException, IOException - Throws:
JdbcExceptionSQLExceptionIOException
-
streamClob
public static void streamClob(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int column, @NonNull MessageBuilder target) throws DbmsException, SQLException, IOException - Throws:
DbmsExceptionSQLExceptionIOException
-
getBlobAsString
public static @Nullable String getBlobAsString(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int column, String charset, boolean blobIsCompressed, boolean blobSmartGet, boolean encodeBlobBase64) throws IOException, JdbcException, SQLException - Throws:
IOExceptionJdbcExceptionSQLException
-
getBlobAsString
public static String getBlobAsString(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, String column, String charset, boolean blobIsCompressed, boolean blobSmartGet, boolean encodeBlobBase64) throws IOException, JdbcException, SQLException - Throws:
IOExceptionJdbcExceptionSQLException
-
getBlobOutputStream
public static OutputStream getBlobOutputStream(@NonNull IDbmsSupport dbmsSupport, @NonNull Object blobUpdateHandle, @NonNull ResultSet rs, int columnIndex, boolean compressBlob) throws SQLException, DbmsException - Throws:
SQLExceptionDbmsException
-
getClobAsString
public static String getClobAsString(@NonNull IDbmsSupport dbmsSupport, @NonNull ResultSet rs, int columnIndex, boolean xmlEncode) throws IOException, JdbcException, SQLException - Throws:
IOExceptionJdbcExceptionSQLException
-
fullClose
-
fullClose
Note: Depending on the connect pool used (for example with Tomcat 7) the connection retrieved from the statement will be the direct connection instead of the proxied connection. After a close on this (unproxied) connection the transaction manager isn't able to do a commit anymore. Hence, this method doesn't get it from the statement but has an extra connection parameter.- Parameters:
connection- the proxied/original connection the statement was created withstatement- the statement to close
-
close
-
isQueryResultEmpty
public static boolean isQueryResultEmpty(@NonNull Connection connection, @NonNull String query) throws JdbcException - Throws:
JdbcException
-
applyParameters
public static void applyParameters(@NonNull IDbmsSupport dbmsSupport, @NonNull PreparedStatement statement, @Nullable ParameterList parameters, Message message, PipeLineSession session) throws JdbcException, ParameterException - Throws:
JdbcExceptionParameterException
-
applyParameters
public static void applyParameters(@NonNull IDbmsSupport dbmsSupport, @NonNull PreparedStatement statement, @NonNull ParameterValueList parameters) throws JdbcException - Throws:
JdbcException
-
mapParameterTypeToSqlType
public static SQLType mapParameterTypeToSqlType(@NonNull IDbmsSupport dbmsSupport, @NonNull ParameterType parameterType) -
setParameter
public static void setParameter(PreparedStatement statement, int parameterIndex, String value, boolean parameterTypeMatchRequired) throws SQLException Set a parameter in a prepared statement. Optimized for single-parameter statements- Throws:
SQLException
-
setParameter
public static void setParameter(@NonNull PreparedStatement statement, int parameterIndex, @Nullable String value, boolean parameterTypeMatchRequired, @Nullable ParameterMetaData parameterMetaData) throws SQLException Set a parameter in a prepared statement. IfparameterTypeMatchRequired = truethen you should also passParameterMetaData. Intended for use when multiple parameters need to be set in the prepared statement, so that ParameterMetaData is fetched only once. (For some databases every time this is accessed from the statement can mean another network-access and fetching it once for all parameters reduces the network overhead for those).- Throws:
SQLException
-
getValueAsMessage(IDbmsSupport, ResultSet, int, ResultSetMetaData, String, boolean)because it is more flexible, and the result can always still be turned into a String value withMessage.asString().