The Persistence.xml File

This file is used to override the default Hibernate settings and to add support for database types that are not out of the box (OOB database types are Oracle Server, Microsoft SQL Server, and MySQL).

If you need to support a new database type, make sure that you supply a connection pool provider (the default is c3p0) and a JDBC driver for your database (put the *.jar files in the adapter folder).

To see all available Hibernate values that can be changed, check the org.hibernate.cfg.Environment class (for details, refer to http://www.hibernate.org.)

Example of the persistence.xml File:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
    <!-- Don't change this value -->
    <persistence-unit name="GenericDBAdapter">
        <properties>
            <!--  Don't change this value  -->
            <property name="hibernate.archive.autodetection" value="class, 
		hbm" />
            <!--The driver class name"/-->
            <property name="hibernate.connection.driver_class" value="com.
              mercury.jdbc.MercOracleDriver" />
            <!--The connection url"/-->
            <property name="hibernate.connection.url" value="jdbc:mercury:
              oracle://artist:1521;sid=cmdb2" />
            <!--DB login credentials"/-->
            <property name="hibernate.connection.username" value="CMDB" />
            <property name="hibernate.connection.password" value="CMDB" />
            <!--connection pool properties"/-->
            <property name="hibernate.c3p0.min_size" value="5" />
            <property name="hibernate.c3p0.max_size" value="20" />
            <property name="hibernate.c3p0.timeout" value="300" />
            <property name="hibernate.c3p0.max_statements" value="50" />
            <property name="hibernate.c3p0.idle_test_period" value="3000" />
            <!--The dialect to use-->
            <property name="hibernate.dialect" value="org.hibernate.dialect.
		OracleDialect" />
        </properties>
    </persistence-unit>
</persistence>

Connect to Database Using NT Authentication

It is possible to connect to an MS SQL Server that requires NT authentication. To do so a driver that can parse domain is needed (that is, jTDS JDBC Driver).

The authentication is done according to the given parameters (domain, username, password), and not with the current running process NT credentials.

  1. In the persistence.xml edit the following properties as follows:

    <!--The driver class name"/-->
    <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver"/>
    <property name="hibernate.connection.url" value="jdbc:jtds:sqlserver://[host name]:[port];DatabaseName=[database name];domain=[the domain]"/>
    <!--DB login credentials"/-->
    <property name="hibernate.connection.username" value="[username]"/>
    <property name="hibernate.connection.password" value="[password]"/>
  2. Place the JDBC driver file under: <probe installation folder>\lib\.

  3. Restart the probe.

Configure the Persistence.xml File for the SCCM Integration to Use NTLM Authentication

Note: This section applies to the SCCM integration only.

In order for the SCCM integration to use NTLM authentication, configure the persistence.xml file as follows:

  1. Place the JDBC driver file under: <probe installation folder>\lib\.

    For example, you can put the jtds-1.3.1.jar file from http://sourceforge.net/projects/jtds/files/ in the DataFlowProbe\lib\ folder.

  2. Start the server and the probe.

  3. In UCMDB, go to Data Flow Management > Adapter Management > SCCMAdapter > .

  4. In the Resources pane, select the SCCM adapter configuration file in the Packages > SCCMAdapter > Configuration Files folder.

  5. In the adapter.conf file, set dal.use.persistence.xml=true.

  6. In the persistence.xml file, add the following:

    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
    "http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
    <persistence-unit name="GenericDBAdapter">
    <properties>
    <!-- added to fix: org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection avalable -->
    <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
    <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
    <!--The driver class name"/-->
    <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver"/>
    <property name="hibernate.connection.url" value="jdbc:jtds:sqlserver://<DB_host>:<port>;DatabaseName=<DB_name>;domain=<domain_name> "/>
    </properties>
    </persistence-unit>
    </persistence>
    Note: Replace the highlighted part with your connection URL.
  7. No user or password is required in the persistence.xml file.

  8. Go to Data Flow Management > Integration Studio, and click the New Integration Point button.

  9. Provide values for required fields.

    When you are required to enter credential ID, do the following:

    1. In the Choose Credential dialog box, select Generid DB Protocol (SQL) from the left Protocol pane.
    2. In the right Credentials pane, click the Create new connection details for selected protocol type button.
    3. In the new dialog box, select MicrosoftSQLServerNTLM as database type.
    4. Enter a port number.

    5. Provide a username in the following format: domain\username.

    6. Provide a password.

Parent topic: Adapter Configuration Files