Spring JDBC 与 Derby 存储过程
Derby 文档 syscs_util.syscs_backup_database。
我创建了以下简单的类:
public class DerbyMemoryDatabaseDumpDao extends JdbcDaoSupport {
private SimpleJdbcCall caller;
@PostConstruct
public void initialize() {
caller = new SimpleJdbcCall(getDataSource()).withCatalogName("SYSCS_UTIL")
.withProcedureName("SYSCS_BACKUP_DATABASE");
}
public void dumpDatabase(String whereTo) {
SqlParameterSource in = new MapSqlParameterSource().addValue("BACKUPDIR", whereTo);
caller.execute(in);
}
}
并获得以下指示,表明 Spring JDBC 3.0.4 无法理解这种情况。我不知道如何使用位置?为此,甚至只是将参数硬编码到调用中(尽管我几乎没有触及这个表面)。
2258 [main] DEBUG org.springframework.jdbc.core.metadata.CallMetaDataProviderFactory - Using org.springframework.jdbc.core.metadata.DerbyCallMetaDataProvider
2258 [main] DEBUG org.springframework.jdbc.core.metadata.CallMetaDataProvider - Retrieving metadata for null/SA/SYSCS_BACKUP_DATABASE
2862 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
2863 [main] DEBUG org.springframework.jdbc.core.simple.SimpleJdbcCall - Compiled stored procedure. Call string is [{call SYSCS_UTIL.SYSCS_BACKUP_DATABASE()}]
2863 [main] DEBUG org.springframework.jdbc.core.simple.SimpleJdbcCall - SqlCall for procedure [SYSCS_BACKUP_DATABASE] compiled
2864 [main] DEBUG org.springframework.jdbc.core.metadata.CallMetaDataContext - Matching [BACKUPDIR] with []
2864 [main] DEBUG org.springframework.jdbc.core.metadata.CallMetaDataContext - Found match for []
2865 [main] DEBUG org.springframework.jdbc.core.simple.SimpleJdbcCall - The following parameters are used for call {call SYSCS_UTIL.SYSCS_BACKUP_DATABASE()} with: {}
2866 [main] DEBUG org.springframework.jdbc.core.JdbcTemplate - Calling stored procedure [{call SYSCS_UTIL.SYSCS_BACKUP_DATABASE()}]
2866 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
2866 [main] DEBUG org.springframework.jdbc.datasource.SimpleDriverDataSource - Creating new JDBC Driver Connection to [jdbc:derby:memory:testdb;create=true]
Derby documents syscs_util.syscs_backup_database.
I made the following trivial class:
public class DerbyMemoryDatabaseDumpDao extends JdbcDaoSupport {
private SimpleJdbcCall caller;
@PostConstruct
public void initialize() {
caller = new SimpleJdbcCall(getDataSource()).withCatalogName("SYSCS_UTIL")
.withProcedureName("SYSCS_BACKUP_DATABASE");
}
public void dumpDatabase(String whereTo) {
SqlParameterSource in = new MapSqlParameterSource().addValue("BACKUPDIR", whereTo);
caller.execute(in);
}
}
And was rewarded with the following indication that Spring JDBC 3.0.4 is failing to make sense of the situation. I can't see how to just use a positional ? for this purpose, or even to just hard-code the parameter into the call (though I've barely scratched that surface).
2258 [main] DEBUG org.springframework.jdbc.core.metadata.CallMetaDataProviderFactory - Using org.springframework.jdbc.core.metadata.DerbyCallMetaDataProvider
2258 [main] DEBUG org.springframework.jdbc.core.metadata.CallMetaDataProvider - Retrieving metadata for null/SA/SYSCS_BACKUP_DATABASE
2862 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
2863 [main] DEBUG org.springframework.jdbc.core.simple.SimpleJdbcCall - Compiled stored procedure. Call string is [{call SYSCS_UTIL.SYSCS_BACKUP_DATABASE()}]
2863 [main] DEBUG org.springframework.jdbc.core.simple.SimpleJdbcCall - SqlCall for procedure [SYSCS_BACKUP_DATABASE] compiled
2864 [main] DEBUG org.springframework.jdbc.core.metadata.CallMetaDataContext - Matching [BACKUPDIR] with []
2864 [main] DEBUG org.springframework.jdbc.core.metadata.CallMetaDataContext - Found match for []
2865 [main] DEBUG org.springframework.jdbc.core.simple.SimpleJdbcCall - The following parameters are used for call {call SYSCS_UTIL.SYSCS_BACKUP_DATABASE()} with: {}
2866 [main] DEBUG org.springframework.jdbc.core.JdbcTemplate - Calling stored procedure [{call SYSCS_UTIL.SYSCS_BACKUP_DATABASE()}]
2866 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
2866 [main] DEBUG org.springframework.jdbc.datasource.SimpleDriverDataSource - Creating new JDBC Driver Connection to [jdbc:derby:memory:testdb;create=true]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管错误消息建议添加 .withCatalog,但解决方案是 .withSchema。
In spite of the error message which suggested adding .withCatalog, the solution to this was .withSchema, instead.