struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "黄叶" <hyli...@gmail.com>
Subject one error when I use the dbcp in struts,
Date Thu, 24 Aug 2006 01:57:28 GMT
hi, guys.
when I  use the struts and dbcp for configure the database pool.

if the data is very large, the tomcat always throw a exception:

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establishing socket.
2006-8-24 9:50:08
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessorprocessChildren
严重: Exception invoking periodic operation:
java.lang.NullPointerException
        at java.util.Arrays.sort(Arrays.java:1078)
        at org.apache.naming.resources.FileDirContext.list(
FileDirContext.java:885)
        at org.apache.naming.resources.FileDirContext.listBindings(
FileDirContext.java:335)
        at org.apache.naming.resources.ProxyDirContext.listBindings(
ProxyDirContext.java:509)
        at org.apache.catalina.loader.WebappClassLoader.modified(
WebappClassLoader.java:734)
        at org.apache.catalina.loader.WebappLoader.modified(
WebappLoader.java:516)
        at org.apache.catalina.core.StandardContext.backgroundProcess(
StandardContext.java:4654)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren
(ContainerBase.java:1619)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren
(ContainerBase.java:1628)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren
(ContainerBase.java:1628)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(
ContainerBase.java:1608)
        at java.lang.Thread.run(Thread.java:534)
2006-8-24 9:50:18
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessorprocessChildren
严重: Exception invoking periodic operation:
java.lang.NullPointerException
        at java.util.Arrays.sort(Arrays.java:1078)
        at org.apache.naming.resources.FileDirContext.list(
FileDirContext.java:885)
        at org.apache.naming.resources.FileDirContext.listBindings(
FileDirContext.java:335)
        at org.apache.naming.resources.ProxyDirContext.listBindings(
ProxyDirContext.java:509)
        at org.apache.catalina.loader.WebappClassLoader.modified(
WebappClassLoader.java:734)
        at org.apache.catalina.loader.WebappLoader.modified(
WebappLoader.java:516)
        at org.apache.catalina.core.StandardContext.backgroundProcess(
StandardContext.java:4654)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren
(ContainerBase.java:1619)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren
(ContainerBase.java:1628)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren
(ContainerBase.java:1628)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(
ContainerBase.java:1608)
        at java.lang.Thread.run(Thread.java:534)



My Database is  ms sql server

and my jdk version is 1.4.2
and tomcat is : 5.0.28
Struts version is : 1.2.7

My Struts configure is here:

     <data-source type="org.apache.commons.dbcp.BasicDataSource">
         <set-property property="description" value="MS SQL Server data
source"/>
         <set-property property="driverClassName" value="
com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
         <set-property property="maxActive" value="5"/>
         <set-property property="maxWait" value="-1"/>
         <set-property property="defaultAutoCommit" value="true"/>
         <set-property property="username" value="sa"/>
         <set-property property="password" value="123456"/>
         <set-property property="url"
value="jdbc:microsoft:sqlserver://10.2.0.101:1433;databasename=db"/>


My Action code is here:

   public ActionForward execute(ActionMapping mapping,
         ActionForm form,
         HttpServletRequest req,
         HttpServletResponse res )
      throws Exception {

      Connection conn = null;

        try {
         DataSource dataSource = getDataSource(req);
         conn = dataSource.getConnection();
         conn.setAutoCommit(true);

//         conn = DBManager.getConnection();
//         conn.setAutoCommit(true);


         res.setContentType("text/plain;charset=UTF-8");
         PrintWriter out = res.getWriter();

         Parser parser = new Parser(conn, out, servlet.getServletContext
().getRealPath("/upload/add"));
         parser.parse();
      } catch ( Exception sqle ) {
         Exception e = new Exception();
         e.initCause(sqle);
         throw e;
      } finally {
        try {
          conn.close();
         } catch ( Exception e ) {
            System.err.println("DataBase have a Exception : " + e);
         }
      }



      return mapping.findForward("parsesucess");

   }


and I use the connection in Class Parser.

but I directly use the JDBC, but not use the datasource pool
there is not Exception.

why?


Please help me

Thx

Mike.G
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message