Thanks Paul, Could you please give me some code snippet about that factory parameter from the server.xml ?
Thanks again. bruce > You're mising the factory parameter from your server.xml ResourceParams > section. BTW, you don't need that stuff in your struts config file if > you're using JNDI. ----- Original Message ----- From: "Paul Thomas" <[EMAIL PROTECTED]> To: "ZYD" <[EMAIL PROTECTED]> Cc: "struts-user" <[EMAIL PROTECTED]> Sent: Wednesday, November 05, 2003 3:10 AM Subject: Re: What's the best choice for connection pooling with Struts and PostgreSQL > > On 04/11/2003 02:43 ZYD wrote: > > I tried to use Tomcat's datasource pool via JNDI, but things not going > > well. > > > > I got the following exception when I tried to get connection: > > > > org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of > > class ' > > ' for connect URL 'null', cause: > > java.lang.NullPointerException > > at java.util.StringTokenizer.<init>(StringTokenizer.java:146) > > at org.postgresql.Driver.parseURL(Driver.java:251) > > at org.postgresql.Driver.acceptsURL(Driver.java:159) > > at java.sql.DriverManager.getDriver(DriverManager.java:232) > > at > > org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou > > rce.java:743) > > at > > org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource > > .java:518) > > at cpool.struts.action.LogonAction.testJNDI(LogonAction.java:185) > > at cpool.struts.action.LogonAction.execute(LogonAction.java:60) > > .................................................... > > .................................................... > > > > In struts-config.xml, I added the following: > > > > <data-source> > > <set-property property="autoCommit" value="false"/> > > <set-property property="description" value="Data Source > > Configuration"/> > > <set-property property="driverClass" value="org.postgresql.Driver"/> > > <set-property property="maxCount" value="4"/> > > <set-property property="minCount" value="2"/> > > <set-property property="password" value=""/> > > <set-property property="url" value="jdbc:postgresql:cpool"/> > > <set-property property="user" value="cpool"/> > > </data-source> > > > > In server.xml: > > > > <Resource name="jdbc/CPool" auth="Container" > > type="javax.sql.DataSource"/> > > <ResourceParams name="jdbc/CPool"> > > <parameter> > > <name>username</name> > > <value>cpool</value> > > </parameter> > > <parameter> > > <name>password</name> > > <value></value> > > </parameter> > > <parameter> > > <name>driverClassName</name> > > <value>org.postgresql.Driver</value> > > </parameter> > > <parameter> > > <name>url</name> > > <value>jdbc:postgresql:cpool</value> > > </parameter> > > <parameter> > > <name>maxActive</name> > > <value>8</value> > > </parameter> > > <parameter> > > <name>maxIdle</name> > > <value>4</value> > > </parameter> > > </ResourceParams> > > > > Then, I wrote the following method in an Action to test the connection: > > > > public void testJNDI() > > { > > try > > { > > Context initCtx = new InitialContext(); > > Context envCtx = (Context)initCtx.lookup("java:comp/env"); > > if (envCtx != null) > > { > > TTools.consolePrint("LogonAction", "envCtx", envCtx.toString()); > > } > > //DataSource ds = (DataSource)envCtx.lookup("jdbc/CPool"); > > DataSource ds = > > (DataSource)initCtx.lookup("java:comp/env/jdbc/CPool"); > > > > Connection conn = ds.getConnection(); > > if (conn != null) > > { > > TTools.consolePrint(conn, "Conn", conn.toString()); > > } > > conn.close(); > > } > > catch (NamingException e) > > { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > catch (SQLException e) > > { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > } > > > > Does this problem sounds familiar to you ? > > Please give some advice on this, thanks in advance. > > You're mising the factory parameter from your server.xml ResourceParams > section. BTW, you don't need that stuff in your struts config file if > you're using JNDI. > > -- > Paul Thomas > +------------------------------+---------------------------------------------+ > | Thomas Micro Systems Limited | Software Solutions for the Smaller > Business | > | Computer Consultants | > http://www.thomas-micro-systems-ltd.co.uk | > +------------------------------+---------------------------------------------+ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >