3 Replies Latest reply on Feb 1, 2006 4:23 AM by jaikiran

    Problem in getting database connection

    baba79au

      Hi,

      I am using the JBoss App Server, Informix Database.

      I am getting a problem to get the jdbc connection, while my EJB are doing well. When i try to get the database connection from standard java class using this code:

      private Connection getConnection() {
      try {
      //this function returns the initial context
      Context ctx = PbsConfig.getInitialContext();
      DataSource source = (DataSource) ctx.lookup(java:PBSDataSource);
      Connection con = source.getConnection();
      return con;
      } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e.getMessage());
      }
      }

      I am getting this following error:

      javax.naming.NameNotFoundException: PBSDataSource not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:278)
      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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:534)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)

      I am using the Informix database and the cofiguration file informix-ds.xml for this is :


      <?xml version="1.0" encoding="UTF-8"?>

      <local-tx-datasource>
      <jndi-name>PBSDataSource</jndi-name>
      <connection-url>jdbc:informix-sqli://localhost:1302/mydb:INFORMIXSERVER=adb01</connection-url>
      <driver-class>com.informix.jdbc.IfxDriver</driver-class>
      <user-name>sa</user-name>
      sa
      <min-pool-size>5</min-pool-size>
      <max-pool-size>20</max-pool-size>

      <type-mapping>InformixDB</type-mapping>

      </local-tx-datasource>




      So Please suggest me if i'm missing something in configuration.
      thanks.