users@glassfish.java.net

Re: DataSourceDefinition and embedded Derby DB

From: Antonio Goncalves <antonio.mailing_at_gmail.com>
Date: Mon, 5 Dec 2011 21:57:22 +0100

Hi,

It's actually "jdbc:derby:memory:myDB;create=true;user=app;password=app"
(you forgot the memory ;o)

Thanks, it works like a charm !!!

Antonio

2011/12/5, Shalini <shalini.muthukrishnan_at_oracle.com>:
> Hi Antonio,
>
> Could you try using "jdbc:derby:myDB;create=true;user=app;password=app"
> for URL in the DataSourceDefinition?
>
> Thanks
> Shalini.
>
> On Sunday 04 December 2011 02:27 AM, Antonio Goncalves wrote:
>> Hi All,
>>
>> I'm using DataSourceDefinition with CDI and Derby database. I use a
>> utility class to define a datasource and at the same time produce my
>> entity manager :
>>
>> @DataSourceDefinition(name = "java:app/jdbc/myDS",
>> className = "org.apache.derby.jdbc.ClientDataSource",
>> portNumber = 1527,
>> serverName = "localhost",
>> databaseName = "myDB",
>> org.apache.derby.jdbc.EmbeddedDriver
>> user = "app",
>> password = "app",
>> properties = {"createDatabase=create"}
>> )
>> public class DatabaseResource {
>>
>> @Produces
>> @PersistenceContext(unitName = "myPU")
>> @MyDatabase
>> private EntityManager em;
>>
>> }
>>
>> This works fine. For test purpose I want to use Derby in-memory
>> database. I changed the DataSourceDefinition to many different
>> possibilities but can't make it work :
>>
>> @DataSourceDefinition(name = "java:app/jdbc/myDS",
>> className = "org.apache.derby.jdbc.EmbeddedDriver",
>> url = "jdbc:derby:memory",
>> databaseName = "myDB",
>> properties = {"createDatabase=create"}
>> )
>> I've changed the URL to different values, added user & pwd (just in
>> case), got rid of the databaseName attribute and added it to the
>> URL.... but I can't find the right syntax nor can I find any
>> references on the web. In the persistence.xml I have the following and
>> it works, so I think it's a matter of finding the right syntax :
>>
>> <property name="javax.persistence.jdbc.driver"
>> value="org.apache.derby.jdbc.EmbeddedDriver"/>
>> <property name="javax.persistence.jdbc.url"
>> value="jdbc:derby:memory:myDB;create=true"/>
>>
>>
>> Any idea ?
>>
>> Thanks
>> Antonio Goncalves
>


-- 
--
Antonio Goncalves (antonio.goncalves_at_gmail.com)
Software architect
Web site : www.antoniogoncalves.org
Blog: agoncal.wordpress.com
Feed: feeds2.feedburner.com/AntonioGoncalves
Paris JUG leader : www.parisjug.org
LinkedIn: www.linkedin.com/in/agoncal