Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 14th, 2004, 11:18 AM
Registered User
Join Date: Apr 2004
Location: Chicago, IL, .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecttion Pool issues - Sample App

I'm having problems getting my connection pool to initialize in the sample app in chps. 19-20.

I have it set up similar to how the book describes and I cannot get past this error:
java.lang.IllegalStateException: Pool not initialized.
     at com.harrisalternatives.struts.util.ConnectionPool. getInstance(ConnectionPool.java:33)

I'm using the com.mysql.jdbc.Driver instead of the one in the book and the BasicDataSource instead of the GenericDataSource in my DBInitServlet class, but everything else is the same.

Can anyone help me? Below are snippets of my code:

        <servlet-class>com.harrisalternatives.struts.util.DBInitSer vlet</servlet-class>

public class DBInitServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
    try {
        BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName(getInitParameter("driverClas s"));
        ds.setMaxActive(Integer.parseInt(getInitParameter( "maxActive")));
        ds.setMaxWait(Integer.parseInt(getInitParameter("m axWait")));
    } catch (SQLException e) {
        throw new ServletException("Unable to open datasource");

public class ConnectionPool {

    private DataSource ds;
    private static ConnectionPool mySelf;
    private ConnectionPool(DataSource ds) {
        this.ds = ds;

    public static void init(DataSource ds) {
        mySelf = new ConnectionPool(ds);

    public static ConnectionPool getInstance() {
        if (mySelf == null) {
            throw new IllegalStateException("Pool not initialized.");
        return mySelf;
public Connection getConnection() throws SQLException {
    return ds.getConnection();

Any help would be greatly appreciated!

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is anybody have sample app on Zend Framewok snowbydave1 Pro PHP 0 November 18th, 2008 10:52 AM
A question on bookstore sample app and pointbase partho_choudhury JSP Basics 0 April 9th, 2004 02:10 AM
A question on bookstore sample app and pointbase partho_choudhury Pro JSP 0 April 9th, 2004 02:09 AM
A question on bookstore sample app and pointbase partho_choudhury Java Databases 0 April 9th, 2004 02:04 AM

All times are GMT -4. The time now is 01:14 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.