I am grateful to both of you for your help. I feel like I have the 
information I need, and have commenced work on a proof-of-concept. I will 
let you know how it goes

On Tuesday, January 7, 2014 1:17:33 PM UTC-5, Thomas Mueller wrote:
>
> Hi,
>
> Please note the quote is not at the right place, it should be:
>
> conn.createStatement().execute(
>                 "script to 'memFS:script.sql' compression gzip");
>
> > I'm not sure how to clear the in-memory file to get that memory back or 
> how long it lasts in memory?
>
> You could call FileUtils.delete().
>
> But yes, maybe calling "script" and processing the result set is better.
>
> Regards,
> Thomas
>
>
>
>
> On Thursday, January 2, 2014, Ryan How wrote:
>
>>  Sorry, I'm probably confusing you by getting off topic.
>>
>> I think memLZF just stores it compressed in memory. To compress it for 
>> transfer over the wire you want to alter this line to say
>>
>>
>> To read it back you need to do the opposite process, I assume you write 
>> to the file in-memory with something like
>>
>> os = FilePath.get("memFS:script.sql").newOutputStream();
>>
>> then write to the output stream to populate the in-memory file.
>>
>> then
>>
>> conn.createStatement().execute("runscript memFS:script.sql COMPRESSION 
>> GZIP");
>>
>> I'm not sure how to clear the in-memory file to get that memory back or 
>> how long it lasts in memory?
>>
>> You might be safer just using SCRIPT TO, read the script from the result 
>> set, then transfer, then execute the script manually without using 
>> RUNSCRIPT... This in-memory file stuff might just be complicating it, but I 
>> think it's pretty nifty! :)
>>
>>
>>
>>
>> On 2/01/2014 10:40 PM, Rob Oaks wrote:
>>  
>>   Just to be clear (and keeping in mind that I'm new to H2!), to run the 
>> in-memory script would I use:
>>  
>>  
>>  
>> conn.createStatement().execute("runscript 
>> FilePath.get('memFS:script.sql')");
>>  
>>  
>>  
>> Can I also substitute memLZF for memFS so that the compressed version of 
>> the string is being sent over the wire? 
>>  
>>
>> On Thursday, January 2, 2014 6:39:21 AM UTC-5, Thomas Mueller wrote:
>>
>> 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:
>>  
>>   -- 
>> 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