Hi,

> SCRIPT TO mem:myobject COMPRESSION GZIP

You can do that already, using the H2 file system abstraction:

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import org.h2.store.fs.FilePath;
import org.h2.util.IOUtils;
public class TestSimpleDb {
    public static void main(String[] args) throws Exception {
        Connection conn = DriverManager.getConnection(
                "jdbc:h2:mem:test");
        conn.createStatement().execute(
                "create table test(id int) as select 1");
        conn.createStatement().execute(
                "script to 'memFS:script.sql'");
        InputStream in = FilePath.get(
                "memFS:script.sql").newInputStream();
        byte[] script = IOUtils.readBytesAndClose(in, -1);
        System.out.println(new String(script, "UTF-8"));
    }
}

Or you can just run "script" and process the result set.

Regards,
Thomas





On Thu, Jan 2, 2014 at 12:14 PM, Ryan How <[email protected]> wrote:

>  On 2/01/2014 6:40 PM, Thomas Mueller wrote:
>
>  > Would be nice if there was some java in-memory file abstraction
>
>  I don't understand, you can already use the file system abstraction of
> H2. You can also use databases that persist to an in-memory file system,
> using the database URL jdbc:h2:memFS:test or jdbc:h2:memLZF:test. See also
> http://h2database.com/html/advanced.html#file_system
>
>
> I meant that because RUNSCRIPT reads from a file or a URL, it would be
> good to be able to pass it file object that just points to an in memory
> string. Nothing H2 specific, just a way to use the java file API for
> accessing custom data structures.
>
> So he could do something like SCRIPT TO mem:myobject COMPRESSION GZIP,
> which would put the compressed data into some byte[] and then transfer it,
> and then RUNSCRIPT mem:myobject COMPRESSION GZIP which reads from the
> byte array. Would save all the custom compressing / uncompressing and
> manually executing the SQL statements. Not that it would be hard...
>
>   --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to