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