0 Replies Latest reply on Oct 18, 2007 1:50 AM by Advait

    Using JNDI datasource name in Hibernate

    Advait Newbie

      I have created a datasource in Jboss Portal 2.6.1. My test server is windows 2003 and jdk 1.5

      <datasources>
       <local-tx-datasource>
       <jndi-name>jdbc/JbossDS</jndi-name> <connection-url>jdbc:mysql://localhost:3306/jbossportaldb</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>jbossportal</user-name>
       <password>jbossportal</password>
       </local-tx-datasource>
      </datasources>
      


      I refer to this datasource in Hibernate.cfg.xml using this property:
      <property name="connection.datasource">java:/jdbc/JbossDS</property>
      


      But when I run my app it is giving this exception:
      javax.naming.NameNotFoundException: jdbc not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
      at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
      at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
      at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:397)

      Also I want to use PortalDS in hibernate.cfg.xml how can I do that? what will be the value of connection.datasource property?