You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by 黄叶 <hy...@gmail.com> on 2006/08/24 03:57:28 UTC

one error when I use the dbcp in struts,

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

Re: html:optionsCollection usage

Posted by Eider Iturbe <ei...@gmail.com>.
Hi,

In order to use <html:optionCollection> tag, you have to define and set a
"Collection" type object in your ActionForm. In this object, you'll have
your list.

public class myFormBean extends ActionForm
{
private String idSelected = null;
...
private Collection myList = new ArrayList();
...
}

And the Collection is an object collection, and for example, these objects
could be of the following type:

public class modelCollection
{
  private String labelDescription = null;
  private String value = null;
  ...

  public void setLabelDescription(String label){
     this.labelDescription=label;
  }

  public String getLabelDescription(){      return this.labelDescription;
  }

  public void setValue(String value){      this.labelDescription=label;
  }

  public String getValue(){      return this.value;
  }

}

Then, in your jsp you have to write this:

<html:select property="idSelected">
  <html:optionsCollection name="myFormBean"
                          property="myList"
                          value="value"
                          label="labelDescription"/>
</html:select>

I hope this helps you,

-- 
Eider


On 8/25/06, Bumia, Nirav (Cognizant) <Nirav.Bumia@cognizant.com > wrote:
>
>
> Hi can anybody tell me how to use <html:optionsCollection> tag
> I want to use it to dynamically generate the list options.
>
> Thanks.
>
> This e-mail and any files transmitted with it are for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information.
> If you are not the intended recipient, please contact the sender by reply
> e-mail and destroy all copies of the original message.
> Any unauthorised review, use, disclosure, dissemination, forwarding,
> printing or copying of this email or any action taken in reliance on this
> e-mail is strictly
> prohibited and may be unlawful.
>
> Visit us at http://www.cognizant.com
>

Re: one error when I use the dbcp in struts,

Posted by 黄叶 <hy...@gmail.com>.
thx


在06-8-25,Antonio Petrelli <br...@tariffenet.it> 写道:
>
> 黄叶 ha scritto:
> > 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.
>
> MS JDBC driver for SQL Server is very buggy. Use jTDS instead (it's a
> friend's suggestion, I had very bad days with MS driver :-) ):
> http://jtds.sourceforge.net/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: html:optionsCollection usage

Posted by Raghuveer <ra...@infotechsw.com>.
hi sheetal,

A collection with labelvalue bean in Struts UTIL package would solve populating data automatically

in DAO
arlCompany.add(new LabelValueBean(resultSet.getString("Company_Name"),resultSet.getString("Company_ID")));

in ACTION

if(arlCompaniesTemp != null && arlCompaniesTemp.size()>0){ //null and size check of Company collection
    					mainMenuActionForm.setCompanies(arlCompaniesTemp);	//set company details
    				}

in JSP
<html:select property="companyId" size="1" styleClass="inputtype" >
					<html:optionsCollection name="mainMenuActionForm" property="companies"/>  
					</html:select>
-----Original Message-----
From: sheetal [mailto:sheetal.gupta@hsc.com]
Sent: Friday, August 25, 2006 1:52 PM
To: Struts Users Mailing List
Subject: Re: html:optionsCollection usage


Bumia, Nirav (Cognizant) wrote:
> Hi can anybody tell me how to use <html:optionsCollection> tag
> I want to use it to dynamically generate the list options.
>
> Thanks.
>
> This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
> If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
> Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
> prohibited and may be unlawful.
>
>   Visit us at http://www.cognizant.com
>   
     Hi,
    Use this snippet
in Action Class
ArrayList<LabelValueBean> deviceIDList = new ArrayList<LabelValueBean>();
request.setAttribute( deviceIDList, deviceIDList);

<JSP PAGE>
<html:select property="deviceId"   >
         <html:options collection=" deviceIDList"
               property="value" labelProperty="label" /> 
           </html:select>


Hope this helps,
-Sheetal


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:optionsCollection usage

Posted by sheetal <sh...@hsc.com>.
Bumia, Nirav (Cognizant) wrote:
> Hi can anybody tell me how to use <html:optionsCollection> tag
> I want to use it to dynamically generate the list options.
>
> Thanks.
>
> This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
> If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
> Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
> prohibited and may be unlawful.
>
>   Visit us at http://www.cognizant.com
>   
     Hi,
    Use this snippet
in Action Class
ArrayList<LabelValueBean> deviceIDList = new ArrayList<LabelValueBean>();
request.setAttribute( deviceIDList, deviceIDList);

<JSP PAGE>
<html:select property="deviceId"   >
         <html:options collection=" deviceIDList"
               property="value" labelProperty="label" /> 
           </html:select>


Hope this helps,
-Sheetal

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


html:optionsCollection usage

Posted by "Bumia, Nirav (Cognizant)" <Ni...@cognizant.com>.
Hi can anybody tell me how to use <html:optionsCollection> tag
I want to use it to dynamically generate the list options.

Thanks.

This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
prohibited and may be unlawful.

  Visit us at http://www.cognizant.com

Re: one error when I use the dbcp in struts,

Posted by Antonio Petrelli <br...@tariffenet.it>.
黄叶 ha scritto:
> 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.

MS JDBC driver for SQL Server is very buggy. Use jTDS instead (it's a
friend's suggestion, I had very bad days with MS driver :-) ):
http://jtds.sourceforge.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org