Class Script
- All Implemented Interfaces:
Closeable, AutoCloseable, Configurable<Script>
Represents a number of SQL statements delimited by semicolon which will be executed in order in a batch statement.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ScriptRegisters with the handle for cleaning when the handle is closed.voidclose()int[]execute()Execute this script in a batch statementvoidExecute this script as a set of separate statementsReturns the configuration registry associated with this object.final StatementContextReturns the statement context associated with this statement.final HandleLocate the Script and split it into statements.Methods inherited from class SqlStatement
bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindASCIIStream, bindASCIIStream, bindBean, bindBean, bindBeanList, bindBinaryStream, bindBinaryStream, bindBySqlType, bindBySqlType, bindByType, bindByType, bindByType, bindByType, bindByType, bindByType, bindFields, bindFields, bindList, bindList, bindList, bindList, bindList, bindList, bindList, bindMap, bindMethods, bindMethods, bindMethodsList, bindNamedArgumentFinder, bindNull, bindNull, bindNVarchar, bindNVarchar, bindPojo, bindPojo, bindPojo, bindPojo, bindPojo, bindPojo, cleanupHandleCommit, cleanupHandleRollback, defineList, defineList, defineNamedBindings, setQueryTimeout, toStringModifier and TypeMethodDescriptionfinal Scriptbind(int position, boolean value) Bind an argument positionallyfinal Scriptbind(int position, byte value) Bind an argument positionallyfinal Scriptbind(int position, byte[] value) Bind an argument positionallyfinal Scriptbind(int position, char value) Bind an argument positionallyfinal Scriptbind(int position, double value) Bind an argument positionallyfinal Scriptbind(int position, float value) Bind an argument positionallyfinal Scriptbind(int position, int value) Bind an argument positionallyfinal Scriptbind(int position, long value) Bind an argument positionallyfinal Scriptbind(int position, short value) Bind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal Scriptbind(int position, BigDecimal value) Bind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyfinal ScriptBind an argument positionallyUsed if you need to have some exotic parameter bound.final ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal Scriptbind(String name, BigDecimal value) Bind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by namefinal ScriptBind an argument by nameUsed if you need to have some exotic parameter bound.final ScriptBind an Iterable as a SQL array.final ScriptBind a Java array as a SQL array, casting each element to a new type.final ScriptBind an Iterator as a SQL array.final <T> ScriptbindArray(int pos, T... array) Bind a Java array as a SQL array.final ScriptBind an Iterable as a SQL array.final ScriptBind a Java array as a SQL array, casting each element to a new type.final ScriptBind an Iterator as a SQL array.final <T> ScriptBind a Java array as a SQL array.final ScriptbindASCIIStream(int position, InputStream value, int length) Bind an argument positionallyfinal ScriptbindASCIIStream(String name, InputStream value, int length) Bind an argument by nameBinds named parameters from JavaBean properties on the argument.Binds named parameters from JavaBean properties on the bean argument, with the given prefix.final ScriptbindBeanList(String key, List<?> values, List<String> propertyNames) Bind a parameter for each value in the given list * number of property names, and defines an attribute as the comma-separated list of parameter references (using colon prefix).final ScriptbindBinaryStream(int position, InputStream value, int length) Bind an argument positionallyfinal ScriptbindBinaryStream(String name, InputStream value, int length) Bind an argument by namefinal ScriptbindBySqlType(int position, Object value, int sqlType) Bind a value using a specific type fromjava.sql.Typesvia PreparedStatement#setObject(int, Object, int)final ScriptbindBySqlType(String name, Object value, int sqlType) Bind a value using a specific type fromjava.sql.Typesvia PreparedStatement#setObject(int, Object, int)final ScriptbindByType(int position, Object value, Type argumentType) Bind an argument dynamically by the type passed in.final ScriptbindByType(int position, Object value, GenericType<?> argumentType) Bind an argument dynamically by the generic type passed in.final ScriptbindByType(int position, Object value, QualifiedType<?> argumentType) Bind an argument dynamically by the qualified type passed in.final ScriptbindByType(String name, Object value, Type argumentType) Bind an argument dynamically by the type passed in.final ScriptbindByType(String name, Object value, GenericType<?> argumentType) Bind an argument dynamically by the generic type passed in.final ScriptbindByType(String name, Object value, QualifiedType<?> argumentType) Bind an argument dynamically by the type passed in.bindFields(Object object) Binds public fields of the specified object as arguments for the query.bindFields(String prefix, Object object) Binds public fields of the specified object as arguments for the query.final Scriptfinal Scriptfinal Scriptfinal ScriptbindList(BiConsumer<SqlStatement, String> onEmpty, String key, Iterable<?> values) final ScriptbindList(BiConsumer<SqlStatement, String> onEmpty, String key, Object... values) final ScriptbindList(BiConsumer<SqlStatement, String> onEmpty, String key, Iterator<?> values) final ScriptbindList(BiConsumer<SqlStatement, String> onEmpty, String key, List<?> values) Bind a parameter for each value in the given list, and defines an attribute as the comma-separated list of parameter references (using colon prefix).Binds named parameters from a map of String to Object instancesbindMethods(Object object) Binds methods with no parameters on the argument.bindMethods(String prefix, Object object) Binds methods with no parameters on the argument, with the given prefix.final ScriptbindMethodsList(String key, Iterable<?> values, List<String> methodNames) For each value given, create a tuple by invoking each given method in order, and bind the tuple into aVALUES (...)format insert clause.bindNamedArgumentFinder(NamedArgumentFinder namedArgumentFinder) Binds a newNamedArgumentFinder.final ScriptbindNull(int position, int sqlType) Bind NULL to be set for a given argument.final ScriptBind NULL to be set for a given argument.final ScriptbindNVarchar(int position, String value) Bind aStringargument positionally, asNVARCHARtype.final ScriptbindNVarchar(String name, String value) Bind aStringargument by name, asNVARCHARtype.Binds named parameters from object properties on the argument.Binds named parameters from object properties on the argument.bindPojo(Object pojo, GenericType<?> type) Binds named parameters from object properties on the argument.Binds named parameters from object properties on the bean argument, with the given prefix.Binds named parameters from object properties on the bean argument, with the given prefix.bindPojo(String prefix, Object pojo, GenericType<?> type) Binds named parameters from object properties on the bean argument, with the given prefix.Transfer ownership of the handle to the statement: when the statement is closed, commit the handle's transaction (if one exists) and close the handle.When the statement is closed, roll it back then close the owning Handle.final ScriptdefineList(String key, Object... values) Define an attribute as the comma-separatedStringfrom the elements of thevaluesargument.final ScriptdefineList(String key, List<?> values) Define an attribute as the comma-separatedStringfrom the elements of thevaluesargument.Define all bound arguments that don't already have a definition with a boolean indicating their presence.setQueryTimeout(int seconds) Set the query timeout, in seconds, on the prepared statement.toString()Methods inherited from interface Configurable
addCustomizer, configure, define, getConfig, registerArgument, registerArgument, registerArrayType, registerArrayType, registerArrayType, registerArrayType, registerCodecFactory, registerCollector, registerCollector, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerExtension, registerRowMapper, registerRowMapper, registerRowMapper, registerRowMapper, setMapKeyColumn, setMapValueColumn, setSqlArrayArgumentStrategy, setSqlLogger, setSqlParser, setTemplateEngine, setTimingCollectorModifier and TypeMethodDescriptiondefault ScriptaddCustomizer(StatementCustomizer customizer) default <C extends JdbiConfig<C>>
ScriptPasses the configuration object of the given type to the configurer, then returns this object.default ScriptConvenience method forgetConfig(SqlStatements.class).define(key, value)default <C extends JdbiConfig<C>>
CGets the configuration object of the given type, associated with this object.default ScriptregisterArgument(ArgumentFactory factory) Convenience method forgetConfig(Arguments.class).register(factory)default ScriptregisterArgument(QualifiedArgumentFactory factory) Convenience method forgetConfig(Arguments.class).register(factory)default ScriptregisterArrayType(Class<?> elementType, String sqlTypeName) Convenience method forgetConfig(SqlArrayTypes.class).register(elementType, sqlTypeName)default <T> ScriptregisterArrayType(Class<T> elementType, String sqlTypeName, Function<T, ?> conversion) Convenience method for registering an array type asSqlArrayTypeFactory.of(Class, String, Function).default ScriptregisterArrayType(SqlArrayType<?> arrayType) Convenience method forgetConfig(SqlArrayTypes.class).register(arrayType)default ScriptregisterArrayType(SqlArrayTypeFactory factory) Convenience method forgetConfig(SqlArrayTypes.class).register(factory)default ScriptregisterCodecFactory(CodecFactory codecFactory) Convenience method to register aCodecFactory.default ScriptregisterCollector(Type collectionType, Collector<?, ?, ?> collector) Convenience method forgetConfig(JdbiCollectors.class).register(CollectorFactory.collectorFactory(collectionType, collector))default ScriptregisterCollector(CollectorFactory factory) Convenience method forgetConfig(JdbiCollectors.class).register(factory)default ScriptregisterColumnMapper(Type type, ColumnMapper<?> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default <T> ScriptregisterColumnMapper(GenericType<T> type, ColumnMapper<T> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default ScriptregisterColumnMapper(ColumnMapper<?> mapper) Convenience method forgetConfig(ColumnMappers.class).register(mapper)default ScriptregisterColumnMapper(ColumnMapperFactory factory) Convenience method forgetConfig(ColumnMappers.class).register(factory)default ScriptConvenience method forgetConfig(ColumnMappers.class).register(factory)default <T> ScriptregisterColumnMapper(QualifiedType<T> type, ColumnMapper<T> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default ScriptregisterExtension(ExtensionFactory factory) Convenience method forgetConfig(Extensions.class).register(factory)default ScriptregisterRowMapper(Type type, RowMapper<?> mapper) Convenience method forgetConfig(RowMappers.class).register(type, mapper)default <T> ScriptregisterRowMapper(GenericType<T> type, RowMapper<T> mapper) Convenience method forgetConfig(RowMappers.class).register(type, mapper)default ScriptregisterRowMapper(RowMapper<?> mapper) Convenience method forgetConfig(RowMappers.class).register(mapper)default ScriptregisterRowMapper(RowMapperFactory factory) Convenience method forgetConfig(RowMappers.class).register(factory)default ScriptsetMapKeyColumn(String keyColumn) Convenience method forgetConfig(MapEntryMappers.class).setKeyColumn(keyColumn)default ScriptsetMapValueColumn(String valueColumn) Convenience method forgetConfig(MapEntryMappers.class).setValueColumn(valueColumn)default ScriptConvenience method forgetConfig(SqlArrayTypes.class).setArgumentStrategy(strategy)default ScriptsetSqlLogger(SqlLogger sqlLogger) default ScriptsetSqlParser(SqlParser parser) Convenience method forgetConfig(SqlStatements.class).setSqlParser(rewriter)default ScriptsetTemplateEngine(TemplateEngine templateEngine) Convenience method forgetConfig(SqlStatements.class).setTemplateEngine(rewriter)default ScriptsetTimingCollector(TimingCollector collector) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
Script
-
Script
-
-
Method Details
-
execute
public int[] execute()Execute this script in a batch statement- Returns:
- an array of ints which are the results of each statement in the script
-
executeAsSeparateStatements
public void executeAsSeparateStatements()Execute this script as a set of separate statements -
getStatements
-
getHandle
-
getConfig
Description copied from interface:ConfigurableReturns the configuration registry associated with this object.- Specified by:
getConfigin interfaceConfigurable<This>- Returns:
- the configuration registry associated with this object.
-
getContext
Returns the statement context associated with this statement.- Returns:
- the statement context associated with this statement.
-
attachToHandleForCleanup
Registers with the handle for cleaning when the handle is closed.
There are some situations where Statements need to be cleaned up to avoid resource leaks. This method registers the current Statement it with the Handle. If the statement or the context are cleaned by themselves, it will automatically unregister, so in normal operations, resources should not pool for cleanup with the Handle.- Since:
- 3.35.0
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
Configurable.setSqlLogger(SqlLogger)instead