users@glassfish.java.net

Re: Use Oracle with Glassfis2 u2 for JPA

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 18 Nov 2008 10:28:19 -0800

Properties will be used if you create the EMF yourself via Persistence.create...
call. In Java EE container when you inject an EM or an EMF, datasource rules
apply. As you didn't specify yours, the container falls back into ints default
(which is JavaDB).

Regards,
-marina

glassfish_at_javadesktop.org wrote:
> Hi. I am trying to use glassfish fot persistence. The database I am using is Oracle 10g XE. I configured the persistence.xml file, but it doesn't work. I think TopLink is trying to connect to (the default Derby??) database on localhost on port 1527. Pleasee see my config file:
> [code]
> <persistence-unit name="TestEJB">
> <properties>
> <property name="toplink.jdbc.driver" value="oracle.jdbc.OracleDriver" />
> <property name="toplink.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:XE" />
> <property name="toplink.jdbc.user" value="rafal" />
> <property name="toplink.jdbc.password" value="duuuh"/>
> <property name="toplink.logging.level" value="FINEST"/>
> </properties>
> </persistence-unit>
> [/code]
> The root cause of the problems I have is the following:
> [code]
> Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/17/2008))): oracle.toplink.essentials.exceptions.DatabaseException
> Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
> Error Code: 0
> [/code]
> The EntityManager is injected like this:
> [code]
> @PersistenceContext(unitName = "TestEJB")
> private EntityManager em;
> [/code]
> The database does work, I can both test the connection in Eclipse, and connect to the db from a simple test application in JavaSE.
> When I check the logs, it turns out that TopLink is using the user, password and logging level, but the driver class or jdbc url are not mentioned anywhere in the log output. What needs to be done so that it starts working? Any link will be helpful.
> Thank you.
> [Message sent by forum member 'szczyp' (szczyp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=317320
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>