Commit Graph

74 Commits

Author SHA1 Message Date
Juergen Hoeller
86ef22db49 Backported "Work around JDK7 String#substring performance regression"
Issue: SPR-9781
Issue: SPR-9784
2012-10-10 23:33:51 +02:00
Oliver Gierke
0769d53a6a Use transactional connection during db population
Previously, DatabasePopulatorUtils#execute looked up a Connection from
the given DataSource directly which resulted in the executed statements
not being executed against a transactional connection (if any) which in
turn resulted in the statements executed by the populator potentially
not being rolled back.

Now DataSourceUtils#getConnection is used to transparently take part in
any active transaction and #releaseConnection is used to ensure the
connection is closed if appropriate.

Issue: SPR-9465
Backport-Issue: SPR-9457
Backport-Commit: 49c9a2a915
2012-06-27 23:06:04 +02:00
Juergen Hoeller
ee9b9d6a57 JDBC parameter binding uses JDBC 3.0 ParameterMetaData (if available) for type determination 2012-03-14 16:54:22 +01:00
Juergen Hoeller
ddf0d071ad revised CustomSQLExceptionTranslatorRegistry/Registrar method naming 2012-02-14 21:29:22 +01:00
Thomas Risberg
f6c7d99ba4 Improvements for registering custom SQL exception translators in app contexts.
Adding a static CustomSQLExceptionTranslatorRegistry and a CustomSQLExceptionTranslatorRegistrar that can be used to register custom SQLExceptionTranslator implementations for specific databases from any application context.

This can be used in application contexts like this:

  <bean class="org.springframework.jdbc.support.CustomSQLExceptionTranslatorRegistrar">
    <property name="sqlExceptionTranslators">
      <map>
        <entry key="H2">
          <bean class="com.yourcompany.data.CustomSqlExceptionTranslator"/>
        </entry>
      </map>
    </property>
  </bean>

Issue: SPR-7675
2012-02-09 17:43:05 -05:00
Thomas Risberg
9fb6e2313c Fix single quote parsing in NamedParameterUtils
Prior to this change, single quotes were incorrectly parsed by
NamedParameterUtils#parseSqlStatement, resulting in incorrect parameter
counts:

    ParsedSql sql = NamedParameterUtils
            .parseSqlStatement("SELECT 'foo''bar', :xxx FROM DUAL");
    assert sql.getTotalParameterCount() == 0 // incorrect, misses :xxx

That is, presence of the single-quoted string caused the parser to
overlook the named parameter :xxx.

This commit fixes the parsing error such that:

    ParsedSql sql = NamedParameterUtils
            .parseSqlStatement("SELECT 'foo''bar', :xxx FROM DUAL");
    assert sql.getTotalParameterCount() == 1 // correct

Issue: SPR-8280
2012-02-06 09:47:17 +01:00
Thomas Risberg
2ffa4725cd Allow SELECT statements in ResourceDatabasePopulator
ResourceDatabasePopulator is a component that underlies the database
initialization support within Spring's jdbc: namespace, e.g.:

    <jdbc:initialize-database data-source="dataSource">
        <jdbc:script execution="INIT" location="classpath:init.sql"/>
    </jdbc:initialize-database>

Prior to this commit, ResourceDatabasePopulator#executeSqlScript's use
of Statement#executeUpdate(sql) precluded the possibility of SELECT
statements because returning a result is not permitted by this method
and results in an exception being thrown.

Whether this behavior is a function of the JDBC specification or an
idiosyncracy of certain implementations does not matter as the issue
can be worked around entirely. This commit eliminates use
of #executeUpdate(sql) in favor of #execute(sql) followed by a call
to #getUpdateCount, effectively allowing any kind of SQL statement to
be executed during database initialization.

Issue: SPR-8932
2012-02-06 08:59:28 +01:00
Thomas Risberg
933e22320d SPR-7476 Improving named parameter parsing skipping escaped colons like '\:' and allowing for delimiting parameter names with curly brackets like :{p1} 2011-10-08 12:10:56 +00:00
Thomas Risberg
4f5248bb5c SPR-7476 Improving named parameter parsing skipping escaped colons like '\:' and allowing for delimiting parameter names with curly brackets like :{p1} 2011-10-08 11:48:45 +00:00
Thomas Risberg
aec82fbd4a SPR-7476 Improving named parameter parsing skipping escaped colons like '\:' and allowing for delimiting parameter names with curly brackets like :{p1} 2011-10-07 18:57:32 +00:00
Thomas Risberg
118ee3fce8 SPR-8652 Fixing queryForLong and queryForInt implementation to use correct expected type 2011-10-06 23:58:38 +00:00
David Syer
296099f222 SPR-8592: add SpEL support in <jdbc:/> 2011-08-09 10:17:10 +00:00
Juergen Hoeller
bbcf358a9d jdbc:script's "separator" and "execution" attributes work nested with embedded-database as well; added "encoding" attribute to jdbc:script element; general revision of DatabasePopulator configuration and execution code 2011-07-28 14:19:53 +00:00
David Syer
6933a1af28 SPR-6717: Added support for database destroy scripts 2011-06-06 07:28:25 +00:00
Thomas Risberg
0adcb2ad2e Added batchUpdate method taking a Collection, a batch size and a ParameterizedPreparedStatementSetter as arguments (SPR-6334) 2011-06-05 16:42:24 +00:00
David Syer
14edc9fc03 SPR-7364: added separator property to database populator to deal with things like PL/SQL 2011-06-02 16:22:26 +00:00
David Syer
645631ad2e SPR-6688: Add tests and explicit detection of \ in sql script extractor 2011-06-02 14:28:58 +00:00
Thomas Risberg
f5f738f2b4 SPR-6922 deprecated SimpleJdbcTemplate/SimpleJdbcOperations/SimpleJdbcDaoSupport in favor of JdbcTemplate/NamedParameterJdbcTemplate and related interfaces support classes 2011-04-14 18:44:40 +00:00
Thomas Risberg
939da34869 switched to create the PreparedStatementCreatorFactory using a list of SqlParameters to preserve type names (SPR-7699) 2011-02-09 13:58:30 +00:00
Juergen Hoeller
2433feab09 fixed embedded database exception test 2010-10-09 13:29:22 +00:00
Oliver Gierke
1c6e131746 SPR-7604 - Support multiple embedded databases.
Added missing test configuration file.
2010-10-08 12:40:06 +00:00
Oliver Gierke
ba2bac17de SPR-7604 - Support multiple embedded databases.
Embedded datasources now get their bean ids set as database name to allow multiple databases of the same type in parallel. Refactored tests a little and made BeanDefinitionParser package private to align with the other ones. Adapted changelog accordingly.
2010-10-02 06:30:05 +00:00
Thomas Risberg
90636f66a8 Added support for looking up column values by column label to support CachedRowSetImpl which doesn't allow for column label use (SPR-7506); added some generics; 2010-09-08 18:46:21 +00:00
Juergen Hoeller
1503a139e2 fixed yet another regression with respect to newlines (SPR-7449) 2010-08-10 22:36:36 +00:00
Sam Brannen
e3400f77c9 [SPR-7449] @Ignore'd failing test for regression in ResourceDatabasePopulator. 2010-08-10 21:51:35 +00:00
Juergen Hoeller
7cddb1c50e polishing 2010-08-07 16:52:16 +00:00
Juergen Hoeller
0c6b38b0b5 DataSourceUtils lets timeout exceptions through even for setReadOnly calls (revised; SPR-7226) 2010-05-25 14:10:28 +00:00
David Syer
e4d8651aa9 RESOLVED - issue SPR-6668: Small Connection leak in DataSourceInitializer
http://jira.springframework.org/browse/SPR-6668
2010-01-13 11:00:41 +00:00
David Syer
17887d24a1 RESOLVED - issue SPR-6365: spring-jdbc.xsd script element claims resource patterns can be used for any SQL resource location but this is only supported for initialize-database tag
Grr: classpath*: again...
2009-11-17 08:36:37 +00:00
David Syer
7519162e65 RESOLVED - issue SPR-6365: spring-jdbc.xsd script element claims resource patterns can be used for any SQL resource location but this is only supported for initialize-database tag
Added resource pattern feature to embedded datasource XML parser.
2009-11-17 07:57:35 +00:00
Keith Donald
3f65721ba8 removed new EmbeddedDatabaeBuilder methods that don't seem very useful for embedded scenarios; javadoc polishing 2009-11-17 00:47:34 +00:00
David Syer
35472300ae OPEN - issue SPR-6346: NoSuchMethodException in DerbyEmbeddedDatabaseConfigurer
Added derby test case to EmbeddedDatabaseBuilderTests
2009-11-15 13:17:42 +00:00
David Syer
534f8a4705 RESOLVED - issue SPR-6345: ResourceDatabasePopulator does not handle comments properly when ignoring failures
http://jira.springframework.org/browse/SPR-6345
2009-11-14 09:02:03 +00:00
Keith Donald
2e4fa28ca6 removed embedded databases factory in favor of new useDefaultScripts builder method 2009-11-03 23:19:26 +00:00
Keith Donald
f1d012bffa embeddedd databases convenience factory; builder polishing 2009-11-03 23:05:41 +00:00
David Syer
14e7b46163 RESOLVED - issue SPR-5917: fixed classpath pattern for ANT 2009-10-30 11:51:50 +00:00
David Syer
e9a37e4400 RESOLVED - issue SPR-5917: DataSourceInitializer and namespace support for creating and populating databases
Moved classes but not resources (fixed)
2009-10-30 11:26:45 +00:00
David Syer
747f71f9d2 RESOLVED - issue SPR-5917: DataSourceInitializer and namespace support for creating and populating databases
Tweak initializer to allow placeholders for script locations
2009-10-30 11:09:49 +00:00
David Syer
0db68e1b57 RESOLVED - issue SPR-5917: DataSourceInitializer and namespace support for creating and populating databases
Moved populator to init package and added namespace features
2009-10-30 10:31:37 +00:00
Juergen Hoeller
e56aa91bd7 "data.sql" instead of "test-data.sql" (SPR-6020) 2009-09-23 16:16:40 +00:00
Juergen Hoeller
773bdcded5 changed NamedParameter/SimpleJdbcOperations parameter signatures to accept any Map value type (SPR-6046) 2009-08-27 13:53:00 +00:00
Mark Pollack
97e3b5ca8c SPR-5976 - Upgrade POMS to JUnit 4.6 2009-08-05 17:48:53 +00:00
Thomas Risberg
f4e75deb0a added some additional tests (SPR-3322, SPR-5162) 2009-06-03 20:06:04 +00:00
Thomas Risberg
8079262705 Updated BeanPropertyRowMapper to remove spaces from column names to improve matching to properties (SPR-5758) 2009-06-02 20:58:44 +00:00
Thomas Risberg
fbd0be2d65 added convenience execute method that takes vararg of objects in the order of the parameters plus the corresponding executeFunction/executeObject methods (SPR-4739) 2009-06-01 20:43:39 +00:00
Thomas Risberg
7c053127dd added convenience method that takes vararg of objects in the order of the declared parameters (SPR-5696) 2009-06-01 20:40:08 +00:00
Thomas Risberg
4105957596 added batchUpdate methods to NamedParameterJdbcTemplate (SPR-3322) 2009-05-28 03:15:47 +00:00
Keith Donald
c6c0dd555b removed unused imports 2009-05-16 22:13:21 +00:00
Keith Donald
f3ae7bd961 applied Joris's patch to shutdown Embedded Derby DB; adjusted manifest template to restrict derby version range from 10.5.1. to 10.6 2009-05-16 22:11:18 +00:00
Keith Donald
eee52f8804 derby embedded db support initial commit; shutdown use case needs work 2009-05-16 15:05:28 +00:00