4 Replies Latest reply on Dec 9, 2004 12:08 PM by lords_diakonos

    help with setting up postgres datasource

    lords_diakonos

      I ama newbie at this and I am trying to set up a postgres as a datasource. Could someone please explain where I am going wrong?
      here is my ds

      <datasources>
       <local-tx-datasource>
       <jndi-name>PostgresDS</jndi-name>
       <connection-url>jdbc:postgresql://localhost/test</connection-url>
       <driver-class>org.postgresql.Driver</driver-class>
       <user-name>postgres</user-name>
       <password>xxxxxx</password>
       <!-- sql to call when connection is created
       <new-connection-sql>some arbitrary sql</new-connection-sql>
       -->
      
       <!-- sql to call on an existing pooled connection when it is obtained from pool
       <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
       -->
      
       </local-tx-datasource>
      
      </datasources>
      


      here is the class I am using as a test to call the ds
      package localtest;
      
      import java.sql.*;
      import javax.*;
      
      public class NameTest {
      
      
      
       public NameTest(){
      
       }
      
       public static String getName() {
      String name = "";
       try{
      javax.naming.Context ctx = new javax.naming.InitialContext();
      javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:/PostgresDS");
      Connection con = ds.getConnection();
      PreparedStatement ps = con.prepareStatement("select name from name");
      ResultSet rs = ps.executeQuery();
      while(rs.next()){
      name = rs.getString("name");
      }
      }
       catch(Exception e){
      e.printStackTrace();
      }
      
       return name;
       }
      }


      here are the errors I am getting :-(
      23:25:03,015 WARN [JBossManagedConnectionPool] Throwable while attempting to ge
      t a new connection: null
      org.jboss.resource.JBossResourceException: Could not create connection; - nested
       throwable: (org.jboss.resource.JBossResourceException: Failed to register drive
      r for: org.postgresql.Driver; - nested throwable: (java.lang.ClassNotFoundExcept
      ion: org.postgresql.Driver))
       at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.c
      reateManagedConnection(LocalManagedConnectionFactory.java:168)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.cr
      eateConnectionEventListener(InternalManagedConnectionPool.java:508)