HQL console with datasource

Hello,

In my module, I configured a Datasource and a hibernate facet linked to that datasource.
In the hibernate.cfq.xml, the datasource is referred to as java:/comp/env/jdbc/XXX

When I use the HQL console, it complains that it cannot locate the datasource:
[FATAL] Could not find datasource: java:comp/env/jdbc/XXX
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

what am I doing wrong?
Should IntelliJ provide a jndi context ?

Koen

2 comments
Comment actions Permalink

I'm having the same problem. I've created a workarround by adding an second hibernate.cfg.xml where I hardcoded the connection properties:

<hibernate-configuration>
    <session-factory>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost/myschema</property>
        <property name="connection.isolation">8</property>
        <property name="connection.username">root</property>
        <property name="connection.password">*****</property>
        <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

..............



After that i configured the HQL console to use this second hibernate configuration. The rest of my setup still just uses the first hibernate configuration.


I think it should be possible for Intellij just to use the (Intellij)datasources. Maybe I'm missing someting

Greetings,
Christof

1
Comment actions Permalink

I have the same issue: it works fine when I configure it using a jdbc connection directly

(by specifying connection.url etc.) but it doesn't work when I try it with a JNDI datasource

(although they were assigned in the persistence view and the db connection works when tested as datasource)

 

Here's the IntelliJ error message when using JNDI datasource:

[2018-08-06 13:55:06] org.hibernate.engine.jndi.JndiException: Error parsing JNDI name [java:/xclinical.etms.ds.core]
[2018-08-06 13:55:06] java.lang.RuntimeException: javax.naming.NamingException: JNDI service is disabled

 

Regards,

Ralf

0

Please sign in to leave a comment.