tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason <jason...@asiacontent.com>
Subject Re: How to make DbConnectionBroker from javaexchange.com to work with Mysql?
Date Mon, 23 Apr 2001 02:14:52 GMT
Hi Jeff,

    it works now!  It's the path of the logfile causing the problem.

Thanx

Jason

Jason wrote:

> Hi Jeff,
>
>     this is the example from DbConnectionBroker.  I follow your advise to modify
> this program but get "javaNullPointer exception" when calling "conn =
> myBroker.getConnection()".  By the way, I am using the same JDBC driver
> "org.gjt.mm.mysql.Driver".
>     I've used String dbServer="jdbc:mysql://192.168.36.1:3306/adv" or String
> dbServer="jdbc:mysql://192.168.36.1:3306 or String
> dbServer="jdbc:mysql://192.168.36.1/adv" or String
> dbServer="jdbc:mysql://192.168.36.1" without any success.
> "
>     Any idea?
>
> Thanx
>
> Jason
>
> ---------------------------My code---------------------------
> import com.javaexchange.dbConnectionBroker.*;
>
> public class Example1 extends HttpServlet
> {
>     DbConnectionBroker myBroker;
>     String dbDriver="org.gjt.mm.mysql.Driver";
>     String dbServer="jdbc:mysql://192.168.36.1:3306/adv";
>     String dbLogin="correct_username";
>     String dbPassword="correct_password";
>     int minConns=2;
>     int maxConns=20;
>     String logFile="logfile";
>     double recycleTime=5.0;
>
>     public void init (ServletConfig config) throws ServletException {
>         super.init(config);
>         try
>         {
>           myBroker = new
> DbConnectionBroker(dbDriver,dbServer,dbLogin,dbPassword,minConns,maxConns,logFile,recycleTime);
>
>         }
>         catch (IOException e5)
>         {
>         }
>     }
>
>     public void doGet (HttpServletRequest request, HttpServletResponse response)
> throws ServletException, IOException
>     {
>         PrintStream out = new PrintStream (response.getOutputStream());
>         Connection conn;
>         Statement stmt = null;
>         int thisConnection;
>         response.setContentType ("text/html");
>
>         try {
>             // Get a DB connection from the Broker
>             conn = myBroker.getConnection();
>              .
>              .
>         }
>         catch (...)
>         { }
>     }
> }
> ---------------------------End of My code---------------------------
>
> Jeff Kilbride wrote:
>
> > There's very good documentation and examples at javaexchange.com, but here's
> > a quickie overview:
> >
> > -------------------------------
> > import com.javaexchange.dbConnectionBroker.*;
> >
> > DbConnectionBroker _broker;
> > String dbDriver="org.gjt.mm.mysql.Driver";
> > String dbServer="jdbc:mysql://localhost:3306";
> > String dbLogin="your_login";
> > String dbPassword="your_password";
> > int minConns=2;
> > int maxConns=20;
> > String logFile="path/to/your/log/file";
> > double recycleTime=5.0;
> >
> > _broker = new DbConnectionBroker(dbDriver,
> >                                                          dbServer,
> >                                                          dbLogin,
> >                                                          dbPassword,
> >                                                          minConns,
> >                                                          maxConns,
> >                                                          logFile,
> >                                                          recycleTime);
> >
> > Connection conn = _broker.getConnection();
> >
> > // Normal use of connection here....
> >
> > _broker.freeConnection(conn);
> > -------------------------------
> >
> > I'm assuming you're using the mm.mysql driver and connecting to localhost.
> > If not, you need to change the dbDriver and dbServer strings. At
> > javaexchange.com, there are examples for implementing a Singleton pattern
> > and using inheritance to make it easier to use the connection broker in your
> > code. I suggest you go through the docs. You can even view them online:
> >
> > http://www.javaexchange.com/
> >
> > Thanks,
> > --jeff
> >
> > ----- Original Message -----
> > From: "Jason" <jasonyam@asiacontent.com>
> > To: <tomcat-user@jakarta.apache.org>
> > Sent: Monday, April 16, 2001 7:51 PM
> > Subject: How to make DbConnectionBroker from javaexchange.com to work with
> > Mysql?
> >
> > > Hi everyone,
> > >
> > >     anyone knows how to use DbConnectionBroker from javaexchange.com to
> > > connect to MYSQL instead of to Oracle?  My application is using Mysql
> > > and it runs fine.  Now I want to use connection pooling to improve the
> > > performance before deployment.  However, I cannot make
> > > DbConnectionBroker and Mysql work together.  Any idea?
> > >
> > > Thanx!
> > >
> > > Jason
> > >


Mime
View raw message