Connect to Derby Embedded DB with Squirrel

I am working on a Java+Spring project that uses a Derby Embedded DB to run a suite of Junits. I want to be able to query the Embedded DB using Squirrel SQL client instead of accessing it through my junit tests directly. The reason for this is I am dealing with some very complex data structures and querying with an editor will be quite helpful to construct my test cases. When I run my JUnits in debug, I place a breakpoint after the database is initialized and leave it there, meaning the embedded DB is created at this point. Below shows the spring configuration that wires up the DB.

<bean> <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" /> <property name="url" value="jdbc:derby:memory:unitTestDB;create=true" /> <property name="username" value="sa" /> <property name="password" value="" /> </bean> 

Below shows the console output, the DB is loaded fully at this point...

Executing SQL script from class path resource [mydb/create-schema.sql] Done executing SQL script from class path resource [mydb/create-schema.sql] in 107 ms. Executing SQL script from class path resource [mydb/create-sequences.sql] Done executing SQL script from class path resource [mydb/create-sequences.sql] in 403 ms. Executing SQL script from class path resource [mydb/create-tables.sql] Done executing SQL script from class path resource [mydb/create-tables.sql] in 3844 ms. Executing SQL script from class path resource [mydb/create-views.sql] Done executing SQL script from class path resource [mydb/create-views.sql] in 2118 ms. Executing SQL script from class path resource [mydb/MY_TABLE.sql] Done executing SQL script from class path resource [mydb/MY_TABLE.sql] in 1380 ms. 

I am using the same driver that my junit suite uses and created an alias that looks like below in Squirrel...

enter image description here

I can create a connection but it seems like Squirrel isn't able to load schemas + tables.

enter image description here

What might I be doing wrong here?

1 Answer

I don't think you can have an embedded instance be accessed by more than one JVM process. Since you have create=true in the URL it created another embedded database for your Squirrel client.

See this answer for more information.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like