db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Bortnovskiy <PBortnovs...@Jefferies.com>
Subject Re: In-Memory Apache Derby Tables not visible from "outside"
Date Sat, 16 Jan 2010 00:05:02 GMT
Hello, Kristian:

That was it. Thank you so much for your time and for your help.
The syntax is not that confusing, but I wish that the documentation be a 
bit clearer about it...

May I ask one more, since I have you "online" and it's also an easy one 
for you
(yet not too clear from the documentation).

What threading model needs to be used with the server?
I was under the impression that the NetworkServerControl is a separate 
thread,
but if my app is sleeping or sitting on a breakpoint, the server isn't 
responding
to JDBC requests.

If possible, can you please explain what would be the right way to 
instantiate and start the server
from within the application. Maybe you may even have a snippet of code as 
an example.

Thanks and have a good weekend (you've helped me get un-stuck! ;-D )






Kristian Waagan <Kristian.Waagan@Sun.COM> 
Sent by: Kristian.Waagan@Sun.COM
01/15/2010 06:44 PM
Please respond to
"Derby Discussion" <derby-user@db.apache.org>


To
Derby Discussion <derby-user@db.apache.org>
cc

Subject
Re: In-Memory Apache Derby Tables not visible from "outside"






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. 







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.
Mime
View raw message