2

How do I see MySql connection URL from openshift? I need it to use it in hibernate.cfg.xml When I log onto my account online I only see the username and password.

1 Answer 1

2

On open shift the database is already available in JNDI. It's name is jdbc/MySQLDS.

To use this 'datasource' in hibernate, your hibernate.cfg.xml should look something like this:

    <!-- Database connection settings -->
    <property name="hibernate.connection.datasource">java:comp/env/jdbc/MySQLDB</property>

    <!-- SQL dialect -->
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

    <!-- Mapped annotated entity-->
    <mapping class="org.hibernate.tutorial.domain.Event"/>

</session-factory> 

To help you even mote please tell us if you are using JbossEWS 1.0, 2.0, JBoss AS6, JBoss EAP. Is your app scale, etcetera.

Sign up to request clarification or add additional context in comments.

3 Comments

I am using JBoss app server 7
I am new to hibernate too. so for <property name="hibernate.connection.url"> jdbc:mysql://${env.OPENSHIFT_MYSQL_DB_HOST}:${env.OPENSHIFT_MYSQL_DB_PORT}/${env.OPENSHIFT_APP_NAME} </property>
No, in stead af using <property name="hibernate.connection.url"> use <property name="hibernate.connection.datasource"> as described above. JBoss already has a datasource set up for your application(s)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.