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?