简体   繁体   English

转储H2插入语句

[英]Dump H2 insert statements

Hi How can I dump data only for an instance of H2 In Memory DB. 嗨如何仅为H2 In Memory DB中的实例转储数据。

What I currently have 我现在有什么

    PreparedStatement preparedStatement = connection
            .prepareStatement("SCRIPT SIMPLE NOSETTINGS");
    ResultSet resultSet = preparedStatement.executeQuery();
    response.setContentType("text/plain");
    ServletOutputStream out = response.getOutputStream();
    while (resultSet.next()) {
        String columnValue = resultSet.getString(1);
        out.print(columnValue);
        out.println();

This dumps the entire db structure however not just the insert data. 这会转储整个数据库结构,但不仅仅是插入数据。 Basically what I want to do is backup the data I insert during development mode so the next time the database is started I can script the data back in. 基本上我想要做的是备份我在开发模式下插入的数据,以便下次启动数据库时我可以重新编写数据脚本。

The table structure isn't a problem as it is done by JPA. 表结构不是问题,因为它是由JPA完成的。

To filter out just inserts, you could use: 要过滤掉插入,您可以使用:

if (columnValue.startsWith("INSERT")) {
    out.println(columnValue);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM