Here's the test code I've setup:
public static final String STD_CONNECTION_STRING =
"jdbc:h2:%s;MV_STORE=FALSE";
public static final String MEM_CONNECTION_STRING =
"jdbc:h2:mem:%s;MV_STORE=FALSE";
public void run(String connectionString) {
String filepath = new File("./src/main/resources/gpfp").getAbsolutePath();
//setup initial datasource
JdbcDataSource datasource = new JdbcDataSource();
datasource.setUrl(String.format(connectionString, filepath));
datasource.setUser("sa");
//initialize transaction factory & environment
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("production", transactionFactory,
datasource);
//initialize configuration, aliases, and mappers
Configuration configuration = new Configuration(environment);
configuration.addMapper(SelectAllTester.class);
SqlSessionFactory sqlSessionFactory = new
SqlSessionFactoryBuilder().build(configuration);
SqlSession session = sqlSessionFactory.openSession();
//do stuff
}
I've tested the STD_CONNECTION_STRING and everything is working just fine,
however when I switch to the MEM string I get the following exception:
Caused by: org.h2.jdbc.JdbcSQLException: Error while creating file "mem:C:"
[90062-178]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
at org.h2.message.DbException.get(DbException.java:178)
at org.h2.message.DbException.get(DbException.java:154)
at org.h2.store.fs.FilePathDisk.createDirectory(FilePathDisk.java:264)
at org.h2.store.fs.FileUtils.createDirectory(FileUtils.java:43)
at org.h2.store.fs.FileUtils.createDirectories(FileUtils.java:298)
On Thursday, March 12, 2015 at 1:50:08 PM UTC-4, Thomas Mueller wrote:
>
> Hi,
>
> > but this doesn't work.
>
> We would need more details.
>
> Regards,
> Thomas
>
>
> On Thursday, March 12, 2015, Jason <[email protected] <javascript:>>
> wrote:
>
>> I'm currently using H2 as a persistent datastore, but would like the
>> ability to use in-memory mode.
>>
>> I tried updating the connection string from *jdbc:h2:[filename]* to
>> *jdbc:h2:mem:[filename]* but this doesn't work.
>>
>> Do you always have to script from the persistent store to in-memory or is
>> there another way to do this?
>>
>> --
>> 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/d/optout.
>>
>
--
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/d/optout.