1

I have an eclipse installed at windows xp and everything works fine. My project is GWT with gilead hibernate and the database is oracle.

When i decided to work from home, i just copied the entire eclipse to my flash memory with my workspace to my windows 7.

After that i decided to move from oracle Db to mysql Db, so i change the entire hibernate.cfg.xml file to make ready for mysql, i deleted the ojdbc library and added the mysql connector.

After all of that when i try to run the project the error below is shown:

Could not connect to the database

it's like the eclipse is reading from the old hibernate.cfg.xml file.

So does anybody know what is happening ???

This is my hibernate.cfg.xml file for oracle connetion:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property   name="hibernate.connection.url">jdbc:oracle:thin:@IP:1521:DEVDB10GR2</property>
<property name="hibernate.connection.username">something</property>
<property name="hibernate.connection.password">something</property>
<property name="hibernate.show_sql">true</property>
<property name="format_sql">true</property>
<mapping class="net.school.shared.hibernate.GsWorkingshift"/>
</session-factory>
</hibernate-configuration>

This is my hibernate.cfg.xml file for mySql connetion:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration>
<session-factory name="">
<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  /hibernatetutorial</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.show_sql">true</property>
<property name="format_sql">true</property>
<mapping class="net.school.shared.hibernate.GsWorkingshift"/>
</session-factory>
</hibernate-configuration>

after i do this this error is keep sowing:

Could not connect to oracle

but when i try it on my work PC it works fine.

majd obeid
  • 111
  • 2
  • 6
  • can you paste more stack trace? – Muhammad Imran Tariq Feb 22 '12 at 06:58
  • @imrantariq When i run the project from my Home PC it seems that the eclipse is reading the hibernate.cfg.xml from somewhere else. because i even tried to just change the user-name and password for my oracle connection and also nothing happened. – majd obeid Feb 22 '12 at 08:18
  • Is any of your class is loading hibernate.cfg.xml? or kindly ensure that hibernate.cfg.xml are set in the class path. Perhaps you set that path absolute? – Muhammad Imran Tariq Feb 22 '12 at 09:50
  • I suggest to create a sepearate java class to test jdbc connection by giving these credentials you gave in hibernate.cfg.xml file for mySql – Muhammad Imran Tariq Feb 22 '12 at 10:23
  • @imrantariq i changed my hibernate.cfg.xml to mysql-hibernate.cfg.xml and i make it load from it and also nothing happened. but i forget to mention that i'm using visual source safe code vss. – majd obeid Feb 23 '12 at 06:37

1 Answers1

0

First check your Database sever is live. Connect with any database explorer software to access your database tables. Then clean build your code and try restarting your web server. Problem could be with database server or its credentials.

Muhammad Imran Tariq
  • 22,654
  • 47
  • 125
  • 190