Итак, мы пытаемся сделать резервную копию нашей базы данных, используя следующий скрипт:
public void backup() throws SQLException {
try {
log.info("Trying to connect with DB");
String sqlFilePath = "./Backup_" + LocalDateTime.now() + ".sql";
Query q = em.createNativeQuery(String.format("SCRIPT TO '%s'", sqlFilePath));
log.info(q.getResultList().toString());
}
catch (Exception e){
e.printStackTrace();
throw new SQLException();
}
}
Это работает безупречно на linux, однако наше программное обеспечение должно работать и на Windows, однако в windows я получаю следующее исключение fileNotFoundException:
14:57:29,826 ERROR [stderr] (default task-21) Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.FileNotFoundException: .\Backup_2020-02-25T14:57:29.148621200.sql (The filename, directory name, or volume label syntax is incorrect)"; "./Backup_2020-02-25T14:57:29.148621200.sql"; SQL statement:
14:57:29,826 ERROR [stderr] (default task-21) BACKUP TO './Backup_2020-02-25T14:57:29.148621200.sql' [90031-193]
14:57:29,826 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
14:57:29,826 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.message.DbException.get(DbException.java:168)
14:57:29,827 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.message.DbException.convertIOException(DbException.java:330)
14:57:29,827 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.command.dml.BackupCommand.backupTo(BackupCommand.java:102)
14:57:29,827 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.command.dml.BackupCommand.update(BackupCommand.java:51)
14:57:29,827 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.command.CommandContainer.update(CommandContainer.java:98)
14:57:29,827 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.command.Command.executeUpdate(Command.java:258)
14:57:29,827 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:160)
14:57:29,828 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:146)
14:57:29,828 ERROR [stderr] (default task-21) at org.jboss.ironjacamar.jdbcadapters@1.4.17.Final//org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:537)
14:57:29,828 ERROR [stderr] (default task-21) at org.hibernate@5.3.13.Final//org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
14:57:29,828 ERROR [stderr] (default task-21) ... 107 more
14:57:29,828 ERROR [stderr] (default task-21) Caused by: java.io.FileNotFoundException: .\Backup_2020-02-25T14:57:29.148621200.sql (The filename, directory name, or volume label syntax is incorrect)
14:57:29,828 ERROR [stderr] (default task-21) at java.base/java.io.FileOutputStream.open0(Native Method)
14:57:29,828 ERROR [stderr] (default task-21) at java.base/java.io.FileOutputStream.open(FileOutputStream.java:292)
14:57:29,828 ERROR [stderr] (default task-21) at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
14:57:29,829 ERROR [stderr] (default task-21) at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:124)
14:57:29,829 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.store.fs.FilePathDisk.newOutputStream(FilePathDisk.java:290)
14:57:29,829 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.store.fs.FileUtils.newOutputStream(FileUtils.java:233)
14:57:29,829 ERROR [stderr] (default task-21) at com.h2database.h2@1.4.193//org.h2.command.dml.BackupCommand.backupTo(BackupCommand.java:67)
14:57:29,829 ERROR [stderr] (default task-21) ... 114 more
Любая помощь будет принята с благодарностью! :)