-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Configuring hinernate to work with Oracle
PostPosted: Tue Jul 22, 2008 5:01 pm 
Newbie

Joined: Tue Jun 24, 2008 12:17 pm
Posts: 6
I am using hibernate schema export ant task to (you guessed it) export the schema. It was successful with Derby db and Hsql db, but gives me troubles with Oracle.

First, I've discovered that the configuration is not the same: the url connection string for Oracle should include the user name and password, although they have their very own property. When my hibernate config file had this connection url String:

jdbc:oracle:thin:@host.name.here:1522:db_name

I got the following exception: java.sql.SQLException: invalid arguments in call

I got over that hurdle when I added my username/password to the url like this:
jdbc:oracle:thin:username/password@host.name.here:1522:db_name

I got the idea to try this when read this page:

http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2005-04/msg02064.html

I will elaborate about my other unresolved issue with Oracle in a different post.




Hibernate version:

3.2.6

Name and version of the database you are using:
Oracle 10.2.0.1

ant export schema task
<target name="schemaexport-oracle" description="Generates the database schema with hbm2ddl to a file" depends="compile">
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="compile.path" />
<hibernatetool destdir="${build}">
<annotationconfiguration configurationfile="${config}/test/hibernate-testOraclePersister.cfg.xml" />
<hbm2ddl haltonerror="true" create="true" drop="true" delimiter=";" outputfilename="oracle_sql.ddl" />
</hibernatetool>
</target>

hibernate-testOraclePersister.cfg.xml content:
<?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 name="LoggingServiceAnnotationFactory">

<property name="hibernate.connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>

<property name="hibernate.connection.url">
jdbc:oracle:thin:@host.name.here:1522:db_name
</property>

<property name="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</property>

<property name="username">username</property>

<property name="password">password</property>

<mapping class="nnl.util.logging.domain.Level" />

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


Full stack trace of any exception that occurs:

484 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
[hibernatetool] 500 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
[hibernatetool] 500 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
[hibernatetool] 500 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
[hibernatetool] 515 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@host.name.here:1522:db_name
[hibernatetool] 515 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {}
[hibernatetool] 515 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
[hibernatetool] 515 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection
[hibernatetool] 593 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - schema export unsuccessful
[hibernatetool] java.sql.SQLException: invalid arguments in call
[hibernatetool] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
[hibernatetool] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
[hibernatetool] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
[hibernatetool] at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:236)
[hibernatetool] at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
[hibernatetool] at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
[hibernatetool] at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
[hibernatetool] at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
[hibernatetool] at java.sql.DriverManager.getConnection(DriverManager.java:582)
[hibernatetool] at java.sql.DriverManager.getConnection(DriverManager.java:154)
[hibernatetool] at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
[hibernatetool] at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:28)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:180)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
[hibernatetool] at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:55)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[hibernatetool] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[hibernatetool] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[hibernatetool] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[hibernatetool] at java.lang.reflect.Method.invoke(Method.java:597)
[hibernatetool] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:348)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:357)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[hibernatetool] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
[hibernatetool] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
[hibernatetool] 1 errors occurred while performing <hbm2ddl>.
[hibernatetool] Error #1: java.sql.SQLException: invalid arguments in call
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.