private byte[] inMemSqliteDbBackup() {
byte[] data = null;
try (DSLContext dsl = DSL.using("jdbc:sqlite::memory:") {
...
//insert some data
dsl.execute("backup to " + data); // backup to byte[], but unsupported , a file is needed
dsl.connection(connection -> {
// or, get underlying connection and open inputstream
// but there is no getInputStream in SqliteConnection
});
}
return data;
}
How can we backup in memory sqlite db to byte[] ? I went through SqliteConnection and it does not give an InputStream either.
one option is to not use in memory db by using url as "jdbc:sqlite:/some-location" and then we can use FileUtils.readFileToByteArray(new File(some-location)) , but not sure if we can do the same with in memory sqlite db and still using DSLContext by Jooq.