Skip to main content



      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 08:36 Go to next message
Eclipse UserFriend
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 11:46 Go to previous messageGo to next message
Eclipse UserFriend
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 07:32 Go to previous message
Eclipse UserFriend
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: Wed Jul 16 15:08:43 EDT 2025

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

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

Back to the top