1

I have a question regarding driver specific properties in the persistence.xml. DB2 has some secific properties that need to be set on the DataSource see:

com.ibm.db2.jcc.DB2SimpleDataSource ds = new com.ibm.db2.jcc.DB2SimpleDataSource();
ds.setDriverType(4); // Set driver type
ds.setDatabaseName("******"); // Set location
ds.setServerName("******"); // Set server name
ds.setPortNumber(******); // Set port number
ds.setUser("*******"); // Set user ID
ds.setPassword("*******"); // Set password
ds.setDriverType(4);
ds.setSecurityMechanism(com.ibm.db2.jcc.DB2BaseDataSource.ENCRYPTED_USER_AND_PASSWORD_SECURITY);
ds.setEncryptionAlgorithm(2);
ds.setClientAccountingInformation("********");

When I create the connection in Netbeans it generates following persistence.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence     http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="TEST" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.jdbc.url"     value="jdbc:db2://********:********/********"/>
      <property name="javax.persistence.jdbc.password" value="********"/>
      <property name="javax.persistence.jdbc.driver"     value="com.ibm.db2.jcc.DB2Driver"/>
      <property name="javax.persistence.jdbc.user" value="********"/>
    </properties>    
  </persistence-unit>
</persistence>

Now my question is how to include the missing properties like "DriverType" or "EncryptionAlgorithm" in the persistence.xml. Is there any way to do this or do I need to add them after I got the connection?

exor298
  • 11
  • 1
  • 2
  • Find the answer here [IBM DB2 Database Type 4 Driver](http://docs.oracle.com/cd/E26576_01/doc.312/e24928/jdbc.htm#GSADG00579) – Braj Apr 08 '14 at 07:17
  • Find the answer here [encryptionAlgorithm](http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=%2Fcom.ibm.db2.udb.apdv.java.doc%2Fdoc%2Frjvdsprp.htm) – Braj Apr 08 '14 at 07:21

0 Answers0