aspose file tools
The moose likes Object Relational Mapping and the fly likes Error at session.flush() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Error at session.flush()" Watch "Error at session.flush()" New topic
Author

Error at session.flush()

Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
I am getting the following error, when a call is made at session.flush()

I am using Oracle9. I am not using oracle thin driver. On windows, I configure JDBC-ODBC bridge and datasource name is - test.

When, I ran following code it woked fine for me.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection ("jdbc dbc:test","scott","tiger");

Below is my configuration file.
-------------------------------------------------------------------------------------------
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc dbc:test</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="myemp.hbm.xml"/>
</session-factory>
</hibernate-configuration>

The error
---------------------------------------------------------------------------------------------
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:171)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2048)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:29
7)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at roseindia.tutorial.hibernate.FirstExample.main(FirstExample.java:41)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:1
10)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
... 14 more[/code]

I think, there is problem with Driver/Dialect class but not sure.
Dhananjay Inamdar
Ranch Hand

Joined: Jan 27, 2003
Posts: 128
Hi Ghulam,

Your error log is also giving the following error, as root cause

----------------------------------------------------------
Caused by: java.sql.SQLException: No suitable driver
-----------------------------------------------------------

Please check for the appropriate driver to connect to Oracle 9 database from java.

Thanks
DJDON


Just like you, struggeling to get the right solutions!<br /> <br />Sun Certified Java Programmer 1.5<br /> <br />Target - SCWCD
Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
Tahnks, Its problem with the driver. Does Hibernate support Type-1 JDBC driver?
Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
It worked, when I changed my URL to jdbc racle:thin:@localhost:1521:actualdbname from jdbc dbc:test. Where test is the JDBC-ODBC configuration from control center .....
I am not sure whether Hibernet supports Type-1 driver, which requires client configuration on client machine.

Thanks
 
IntelliJ Java IDE
 
subject: Error at session.flush()
 
Threads others viewed
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection
java.sql.SQLException: No suitable driver
Cannot insert record into Database!
Communication failure during handshake. Is there a server running on localhost:3306?
Problem connecting to Oracle with Hibernate
developer file tools