Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with using hibernate on a remote host

 
Vince Lee
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I have recently finished writing a web application locally, and have deployed the application on a remote host. However, I am having trouble making a connection to the mysql database using hibernate. The situation is this:

1. my application runs on tomcat on server A
2. the mysql database is on a server "mysql5" that is accessible from server A using the name "mysql5". ie. i could access it in a ssh session using mysql -p -u owasclub -h mysql5 owasclub
3. in my hibernate.cfg.xml (under web-inf and root dir), I have:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- mysql db settings -->
<property name="connection.url">jdbc:mysql://mysql5/owasclub</property>
<property name="connection.username">owasclub</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.password">xxxx</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

<!-- thread is the short name for org.hibernate.context.ThreadLocalSessionContext and let Hibernate bind the session automatically to the thread -->
<property name="current_session_context_class">thread</property>

<!-- this will show us all sql statements -->
<property name="hibernate.show_sql">true</property>

...
</session-factory>
</hibernate-configuration>

4. I am using the newest mysql driver (5.x)

The error that I am getting is a TransactionException, Transaction not successfully started. I currently don't have the stack trace because i don't know how to get it saved remotely.

The application used to work when the database was on localhost, so I'm wondering if there's something that has to be done extra for connecting remotely. Any information would be appreciated. Thanks.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just out of curiosity in

"jdbc:mysql://mysql5/owasclub"

What is the ip ort address of the server?

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic