Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Can't get JPA properties passed through to DriverManager
Can't get JPA properties passed through to DriverManager [message #1119419] Sat, 28 September 2013 12:36 Go to next message
William Ferguson is currently offline William FergusonFriend
Messages: 2
Registered: September 2013
Junior Member
I am using ucanaccess as a DB driver and want to be able to pass properties through to the DriverManager#getConnection(url, properties), but I am finding that EclipseLink strips all properties except for user and password.


Eg I have the following config:

    <persistence-unit name="myEMF" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

        <mapping-file>jpa/some-entity-orm.xml</mapping-file>

        <exclude-unlisted-classes>true</exclude-unlisted-classes> <!-- Persist only those classes listed above -->

        <properties>
            <property name="eclipselink.ddl-generation" value="create-tables"/> <!-- Creates the tables if they do not exist. -->

            <!-- Tells ucanaccess that the DB will not be shared. -->
            <property name="singleconnection" value="true"/>
            <property name="javax.persistence.jdbc.singleconnection" value="true"/>
            <property name="any.damn.property" value="someValue"/>

            <property name="javax.persistence.jdbc.driver" value="net.ucanaccess.jdbc.UcanaccessDriver"/>
            <property name="javax.persistence.jdbc.url" value="jdbc:ucanaccess://!!dbFileName!!"/> <!-- Filename needs to be subbed in at runtime -->
            <property name="javax.persistence.jdbc.user" value=""/>
            <property name="javax.persistence.jdbc.password" value=""/> <!-- Get password from Settings -->
        </properties>
    </persistence-unit>


but only get user and password show in UcanaccessDriver#getConnection()


How can I get my properties passed through the UcanaccessDriver#getConnection?
Re: Can't get JPA properties passed through to DriverManager [message #1121412 is a reply to message #1119419] Mon, 30 September 2013 15:46 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
You would use the PersistenceUnitProperties.JDBC_PROPERTY string preface "eclipselink.jdbc.property." to define your property. So
<property name="eclipselink.jdbc.property.<jdbc_connection_property_name>" value="value"/>

If you want to be able to define the URL property at runtime though, you will need to pass in the "javax.persistence.jdbc.url" to the properties used to create the EMF at runtime, as shown here:
http://wiki.eclipse.org/EclipseLink/Examples/JPA/OutsideContainer


Best Regards,
Chris
Re: Can't get JPA properties passed through to DriverManager [message #1122259 is a reply to message #1121412] Tue, 01 October 2013 11:32 Go to previous message
William Ferguson is currently offline William FergusonFriend
Messages: 2
Registered: September 2013
Junior Member
Awesome, thanks Chris. Works exactly as described.
Previous Topic:Where is EclipseLink 2.5 XSD?
Next Topic:Reverse Engineering Legacy Database
Goto Forum:
  


Current Time: Thu Nov 27 10:02:18 GMT 2014

Powered by FUDForum. Page generated in 0.01670 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software