-
Jan 13th, 2006, 03:50 PM
#1
Spring with Hibernate and LDAP Lookup
I am some issues wiring JNDI-based lookup of SybDataSource configuration to the hibernatesession. It's complaining about invalid port (which I should be getting via the Lookup) or it's producing following exception.
2006-01-13 12:50:04,326 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 0, SQLState: JZ006>
2006-01-13 12:50:04,357 ERROR [org.hibernate.util.JDBCExceptionReporter] - <JZ006: Caught IOException: java.net.UnknownHostException: null>
2006-01-13 12:50:04,357 WARN [org.hibernate.cfg.SettingsFactory] - <Could not obtain connection metadata>
java.sql.SQLException: JZ006: Caught IOException: java.net.UnknownHostException: null
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(Erro rMessage.java:493)
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseErrorCheck Dead(ErrorMessage.java:729)
at com.sybase.jdbc2.tds.Tds.handleIOE(Tds.java:3107)
at com.sybase.jdbc2.tds.Tds.login(Tds.java:394)
at com.sybase.jdbc2.jdbc.SybConnection.tryLogin(SybCo nnection.java:218)
at com.sybase.jdbc2.jdbc.SybConnection.regularConnect (SybConnection.java:195)
at com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConn ection.java:174)
at com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConn ection.java:126)
at com.sybase.jdbc2.jdbc.SybDriver.createConnection(S ybDriver.java:533)
at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver. java:473)
I am trying to use "depends-on" to help realize that the dataSource is a result of JNDI lookup but it appears that's not going to do it. Following is my setup.
<bean id="jndiDBTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.object">com.sybase.jdbc2. jdbc.SybObjectFactory</prop>
<prop key="java.naming.factory.initial">com.sun.jndi.lda p.LdapCtxFactory</prop>
<prop key="java.naming.provider.url">ldap://sybaseldap.usa.company.net:4897/dc=sybase,dc=company,dc=com</prop>
</props>
</property>
</bean>
<bean id="jndiLdapBean" class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiTemplate"><ref bean="jndiDBTemplate"/></property>
<property name="jndiName"><value>sybaseServerName=PHASE3</value></property>
</bean>
<bean id="sybaseDataSource" depends-on="jndiLdapBean" class="com.sybase.jdbc2.jdbc.SybDataSource">
<property name="databaseName"><value>sybaseServerName=PHASE3 </value></property>
<property name="user"><value>s20dev</value></property>
<property name="password"><value>s20dev</value></property>
<property name="portNumber"><value>12200</value></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource"><ref bean="sybaseDataSource"/></property>
<property name="mappingResources"><value>vrdn.hbm.xml</value></property>
<property name="hibernateProperties">.........
</property>
</bean>
So, the real question is how can I best wire the sessionFactory to SybDataSource which will have been initialized based on the JNDI lookup?
Thanks for your help.
-
Jan 17th, 2006, 10:55 AM
#2
Spring with Hibernate and LDAP Lookup
Is this doable or am I trying too hard? Thanks.
-
Jan 17th, 2006, 03:23 PM
#3
I resolved this issue by using UserCredentialsDataSourceAdapter class for those who read this thread and were in need of similar solution.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules