Pavel Bortnovskiy wrote:
Hello:
I am writing an application which is using Derby as an in-memory DB:
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
m_connection =
DriverManager.getConnection("jdbc:derby:memory:testdb;create=true");
In that application I am also starting the NetworkServerControl:
try {
NetworkServerControl server = new
NetworkServerControl(InetAddress.getByName("localhost"), 1527);
server.start(new PrintWriter(System.out));
} catch (Exception e) {
logger.error(e);
}
My application seems to run happily, creating and populating tables.
All the tables are well visible from the inside the app, for instance
after "CREATE TABLE" called,
this returns cnt=1:
Statement statement = m_connection.createStatement();
ResultSet rset = statement.executeQuery(
"SELECT COUNT(*) FROM SYS.SYSTABLES WHERE
TABLENAME='SAMPLE_TABLE'");
int cnt = -1;
if (rset.next()) cnt = rset.getInt(1);
However, if I try to connect with another DB client (currently I am
using Aqua Data Studio and it's configured to connect to
jdbc:derby://localhost:1527/testdb;create=true), it connects, but the
tables created in memory are not visible (while SYS tables are):
[ snip - image ]
So, why could it be that in-memory tables aren't seen from the
"outside" and what can be done to make them visible?
Hi Pavel,
From a quick look at the code snippets you posted, it seems to me you
are not connecting to the same database.
Removing "create=true" from the client driver JDBC connection URL should
demonstrate that.
To use an in-memory database with the client driver (or a data source),
you have to use the following URL:
jdbc:derby://localhost:1527/memory:testdb (or for instance
jdbc:derby://myhost:1527/memory:/absolute/path/to/my/testdb)
I agree this isn't obvious, maybe some work can be done to improve it.
Also, there is some information about the in-memory back end at
http://wiki.apache.org/db-derby/InMemoryBackEndPrimer
Hope this helps,
--
Kristian
Much appreciated!
Regards,
Pavel Bortnovskiy.
Jefferies archives and monitors outgoing and incoming e-mail. The
contents of this email, including any attachments, are confidential to
the ordinary user of the email address to which it was addressed. If
you are not the addressee of this email you may not copy, forward,
disclose or otherwise use it or any part of it in any form whatsoever.
This email may be produced at the request of regulators or in
connection with civil litigation. Jefferies accepts no liability for
any errors or omissions arising as a result of transmission. Use by
other than intended recipients is prohibited. In the United Kingdom,
Jefferies operates as Jefferies International Limited; registered in
England: no. 1978621; registered office: Vintners Place, 68 Upper
Thames Street, London EC4V 3BJ. Jefferies International Limited is
authorised and regulated by the Financial Services Authority.