4

My persistence.xml:

<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_2_0.xsd"
  version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
  <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <class>com.ibm.apiscanner.DTO.BaselineDTO</class>
    <properties>
      <property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver" />
      <property name="hibernate.connection.url"    value="jdbc:db2://localhost:{PORT}/{DB}" />
      <property name="hibernate.connection.username" value="{user}" />
      <property name="hibernate.connection.password" value="{password}" />
      <property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect"/>
      <property name="show_sql" value="true"/>
      <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
    </properties>
  </persistence-unit>
</persistence>

I'm presented with the following:

Jan 22, 2015 9:16:48 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.DB2Dialect
Jan 22, 2015 9:16:48 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null

The same url,user and password combination works when connecting via basic JDBC.

Anyone have suggestions?

C_B
  • 2,620
  • 3
  • 23
  • 45
  • 1
    "For me the reason was obvious: connection was null because the database was not responding." I added that as answer, but it was not suitable for someone, thus got downvoted. I leave the information here for completeness, if someone like me stumples to this question with same etimology of symthoms. – mico Sep 06 '17 at 09:18

2 Answers2

1

That's an INFO message (nothing to worry about) because you set:

<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>

By default, if you don't specify this property, it will then be set to true, and a JDBC connection will be used to inspect the database metadata.

So you have two options:

  1. You remove that property
  2. You keep it, but you add this property as well:

    hibernate.jdbc.lob.non_contextual_creation=true
    

    but then you will get some other INFO message, telling that:

    HHH000421: Disabling contextual LOB creation as hibernate.jdbc.lob.non_contextual_creation is true
    
Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
0

It was a driver version problem for me,

-Make you have db2jcc4.jar and it is not conflicting with earlier version .

-Make sure you have specified currentschema

Dapper Dan
  • 932
  • 11
  • 23