-->
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.  [ 15 posts ] 
Author Message
 Post subject: Configuration of Hibernate when providing the connection
PostPosted: Mon Jul 26, 2004 8:33 am 
Newbie

Joined: Tue May 25, 2004 4:24 am
Posts: 13
I tried to find info about the following but failed.

I'm evaluating Hibernate (2.1) as the persistence layer in an existing product.

I'm providing my own connection to the Hibernate session but from looking at the logs,
I realized that when building session factory, Hibernate is still trying to
obtain connection (and failed - java.sql.SQLException: JZ00L: Login failed).

(In this line : sessionFactory = new Configuration().configure().buildSessionFactory();)

How can I configure hibernate to use the provided connections and not obtain new ones?

Bellow is the corresponding configuration file:
<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.url">jdbc:sybase:Tds:myMachine:myPort/theDB</property>
<property name="hibernate.connection.driver_class">com.sybase.jdbc2.jdbc.SybDriver</property>
<property name="hibernate.connection.username">myName</property>
<property name="hibernate.connection.password">myPassword</property>
<property name="hibernate.connection.pool_size">0</property>
<property name="hibernate.statement_cache.size">0</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.SybaseAnywhereDialect</property>

<!-- Mapping files -->

<mapping resource="myFile.hbm.xml"/>

</session-factory>

</hibernate-configuration>

What changes should be made to this file (or elsewhere) to avoid this situation?

Thanks in advance,
Daphna


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 9:04 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Remove this:

<property name="hibernate.connection.username">myName</property>
<property name="hibernate.connection.password">myPassword</property>
<property name="hibernate.connection.pool_size">0</property>
<property name="hibernate.statement_cache.size">0</property>

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 9:41 am 
Newbie

Joined: Tue May 25, 2004 4:24 am
Posts: 13
Thanks for the prompt reply.

The original configuration file didn't include those lines but then I got:


[WARN],(SettingsFactory.java:95),Could not obtain connection metadata,net.sf.hibernate.cfg.SettingsFactory,main
java.sql.SQLException: JZ004: User name property missing in DriverManager.getConnection(..., Properties).
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:549)
at com.sybase.jdbc2.tds.LoginToken.<init>(LoginToken.java:128)
at com.sybase.jdbc2.tds.Tds.doLogin(Tds.java:489)
at com.sybase.jdbc2.tds.Tds.login(Tds.java:432)
at com.sybase.jdbc2.jdbc.SybConnection.tryLogin(SybConnection.java:247)
at com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:223)
at com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:198)
at com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:132)
at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver.java:179)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:95)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1119)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:748)
at com.cisco.nm.vms.common.HibernateUtil.initHibernate(HibernateUtil.java:51)
at com.cisco.nm.vms.common.AthenaStartup.initialize(AthenaStartup.java:110)
at com.cisco.nm.vms.common.web.AthenaStartupServlet.init(AthenaStartupServlet.java:18)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3422)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3623)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:754)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:363)
at org.apache.catalina.core.StandardService.start(StandardService.java:497)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2190)
at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:232)


So it looks like I have no choice but to specify these parameters (at leat name and password).


Thanks,
Daphna


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 9:45 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Ooops, yes, username and password should be there. But not the Hibernate connection pool settings.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 10:09 am 
Newbie

Joined: Tue May 25, 2004 4:24 am
Posts: 13
I'm sure you broke the world record in replying to posts :)

If that's the case ... then the problem still persists
(trying to obtain the connection, though it's not needed):

[WARN],(SettingsFactory.java:95),Could not obtain connection metadata,net.sf.hibernate.cfg.SettingsFactory,main
java.sql.SQLException: JZ00L: Login failed. Examine the SQLWarnings chained to this exception for the reason(s).
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:549)
at com.sybase.jdbc2.tds.Tds.processLoginAckToken(Tds.java:3641)
at com.sybase.jdbc2.tds.Tds.doLogin(Tds.java:510)
at com.sybase.jdbc2.tds.Tds.login(Tds.java:432)
at com.sybase.jdbc2.jdbc.SybConnection.tryLogin(SybConnection.java:247)
at com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:223)
at com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:198)
at com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:132)
at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver.java:179)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:95)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1119)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:748)
at com.cisco.nm.vms.common.HibernateUtil.initHibernate(HibernateUtil.java:51)
at com.cisco.nm.vms.common.AthenaStartup.initialize(AthenaStartup.java:110)
at com.cisco.nm.vms.common.web.AthenaStartupServlet.init(AthenaStartupServlet.java:18)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3422)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3623)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:754)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:363)
at org.apache.catalina.core.StandardService.start(StandardService.java:497)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2190)
at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:232)



Thanks,
Daphna


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 10:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually you need to remove the URL and driver class as well.

Note that this is just a WARN. There is no problem here.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 10:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
And you do not need user/pass.

Just get rid of all connection related properties.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 10:25 am 
Newbie

Joined: Tue May 25, 2004 4:24 am
Posts: 13
So how can I specify which database to access ( I have few) ?

Thanks,
Daphna


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 10:26 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Well, by specifying connection.url, which is a connection pool for a particular database.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 11:03 am 
Newbie

Joined: Tue May 25, 2004 4:24 am
Posts: 13
That brings us back to square one...
since gavin has advised me to get rid of all the connection related properties.

So do I need these connection properties or not?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 11:04 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I'm sorry if some of my postings where confusing you. Remove all connection properties, EXCEPT the connection.url.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 11:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There must be something I don't understand here .... why does he need to specify the URL if he is providing his own connections?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 11:07 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I thought he was using his Tomcat connection pool?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 11:08 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
OMG, I'll stop posting in this thread. Forget all I said.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 28, 2004 11:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
:-)


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

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.