문제

i got a problem when i'm closing an h2 connection(release database) and try to connect to another h2 database(debug database).

Snipplet to connect:

this.connection = new JdbcConnectionSource(connectionString);

Snipplet to disconnect:

this.connection.close();

ConnectionString:

jdbc:h2:file:/data/data/my.app/databases/myapp
jdbc:h2:file:/data/data/my.app/testdatabases/myapp

Then instead of using the "new" connection the old one is used. I'm using different directories for the databases. In both cases when i try to toggle between database1 and database2 the .lock and .trace files are not deleted in their directories.

I want exclude implmentation failures on my side. I'm using h2(current version) with ormlite on android 4.2.2.

도움이 되었습니까?

해결책

Then instead of using the "new" connection the old one is used.

If you are creating a new ConnectionSource then you will need to re-create all of your DAO classes and clear the DAO cache from within the DaoManager. Each of the DAO classes has a copy of the old connection source that it uses.

ConnectionSource connectionSource = new JdbcConnectionSource(connectionString);
DaoManager.clearCache();
Dao<Foo,Integer> fooDao = DaoManager.createDao(connectionSource, Foo.class);
...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top