Spring JDBC 与 Derby 存储过程

发布于 2024-09-25 15:19:47 字数 2160 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧话新听 2024-10-02 15:19:47

尽管错误消息建议添加 .withCatalog,但解决方案是 .withSchema。

In spite of the error message which suggested adding .withCatalog, the solution to this was .withSchema, instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文