• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating jar from project using hibernate

 
Florin Florentin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I created a project in which used hibernate 3 for connecting to my MySql database. The project it's done and it's working, the problem is when i want to open it through my
jar file created after it where compiled, it does not connect to my database.
I added in the project properties the hibernate libraries, i don't know what's missing.

If you can give me a hint, i will appreciate
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing anything more it'll be hard to help... How are you connecting? How are you specifying your connection properties and mappings?

This belongs in the ORM forum.
 
Florin Florentin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have configured the hibernate.cfg.xml file.

I'm connecting to a local database on the port 3306.

<?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>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/db</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">password</property>
<property name="current_session_context_class">thread</property>
<mapping resource="Model/Table1.hbm.xml"/>
<mapping resource="Model/Table2.hbm.xml"/>
<mapping resource="Model/Table3.hbm.xml"/>
<mapping resource="Model/Table4.hbm.xml"/>
</session-factory>
</hibernate-configuration>
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the config file in your jar?
 
Florin Florentin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my jar the config file is located is outside a directory. In my project it is also into a default package.
 
Florin Florentin
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is solved it were a problem with the libraries
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic