Hello Jerome,

Here is how we use poolman to obtain a connection to the datasource.

Hope this helps.

Regards,
Todd G. Nist

// Code from www.husted.com scaffold project

import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;

import com.codestudio.sql.PoolMan;


public final class ConnectionPool {

    /**
     * An exception message to throw if datasource is null.
     */
    public static final String DATASOURCE_ERROR = "Connection pool " +
        "not available. Check your poolman.xml config, and be sure " +
        "you are using a valid dbname parameter (use dbname, not jndiName)";

    /**
     * Returns a JDBC connection from a connection pool or other
     * resource, to be used and closed promptly.
     * <p>
     * @returns JDBC connection from resource layer.
     * @exception SQLException on SQL or other errors. May wrap other
     * exceptions depending on implementation. Will not return null.
     */
    public static final Connection getConnection(String dataSource) throws
SQLException {
        DataSource ds = PoolMan.findDataSource(dataSource);
        if (ds==null)
            throw new SQLException(DATASOURCE_ERROR);
        return(ds.getConnection());
    }
}

Poolman.xml

<!--<?xml version="1.0" encoding="UTF-8"?-->
<poolman>
  <management-mode>local</management-mode>

   <datasource>
      <dbname>sample</dbname>
      <jndiName>jndiSample</jndiName>
      <driver>com.sybase.jdbc2.jdbc.SybDriver</driver>
      <url>jdbc:sybase:Tds:localhost:2638</url>
      <!--next 2 should be in code for production for security -->
      <username>dba</username>
      <password>sql</password>

      <minimumSize>5</minimumSize>
      <maximumSize>10</maximumSize>
      <connectionTimeout>600</connectionTimeout>
      <shrinkBy>5</shrinkBy>
      <logFile>d:\poolman.log</logFile>
      <debugging>true</debugging>
  </datasource>
</poolman>

// call to ConnectionPool.class to get a connection
connection = ConnectionPool.getConnection("jndiSample");

-----Original Message-----
From: Jerome Josephraj [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 08, 2002 3:59 AM
To: Struts Users Mailing List
Subject: Poolman query


Hi,

        Sorry about this out of topic query. But looks like this is the
only place where I can get some help on Poolman.

        I am struggling in setting up poolman to run in silverstream
server.

        All I try to do is, set up a simple poolman configuration just
to access a database in my local server. I am not       using   any JNDI
name.

        Configuration Details :

                Silver stream version : Silver Stream 3.7.3
                Database                    : Sybase adaptive server
anywhere 6.0
                Poolman version       : 2.1


                My poolman.xml looks like this

          <datasource>

                    <dbname>CBSData</dbname>
                    <driver>jdbs:poolman://localhost:80/CBSData</driver>


                    <username>test</username>
                    <password>test</password>

                    <minimumSize>0</minimumSize>
                    <maximumSize>10</maximumSize>

                    <logFile>/home/poolman/logs/testdb.log</logFile>

          </datasource>


                The following is the snippet of the code


        try {
// load the PoolMan JDBC Driver
Class.forName("com.codestudio.sql.PoolMan").newInstance();
} catch (Exception ex) {
System.out.println("Could Not Find the PoolMan Driver. "
"Is poolman.jar in your CLASSPATH?");
}

Connection con = null;
try {

// establish a Connection to the database with
con = DriverManager.getConnection("jdbc:poolman://CBSData");

// Use the Connection to create Statements and do JDBC work
Statement stm = con.createStatement();

} catch (SQLException sqle) { sqle.printStackTrace(); }
finally {
try { con.close(); } catch (SQLException csqle) {}
}


        I get NullPointer exception asa I reach the point where I try to
load the JDBC driver.

        Hope the provided information will do. Any help is greatly
appreciated.



TIA,

Jerome.
  _____

This message contains confidential information and is intended only for
the individual named. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and
delete this e-mail from your system. E-mail transmission cannot be
guaranteed to be secure or error-free as information could be
intercepted, corrupted, lost, destroyed, arrive late or incomplete, or
contain viruses. The sender therefore does not accept liability for any
errors or omissions in the contents of this message, which arise as a
result of e-mail transmission. If verification is required please
request a hard-copy version.

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

Reply via email to