Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5993235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:38:46+00:00 2026-05-22T23:38:46+00:00

I have created 3 classes: The first for connection(Connectionx),the second I’am using it to

  • 0

I have created 3 classes: The first for connection(Connectionx),the second I’am using it to fill UI as checkbox,selectonemenu(BeanTools) and the third is for my “operations”(NumberOfIssue).
1)The problem that I want to connect to the database just a once ,I have done the connection in the class Connectionx and I want to use the same connection on all my Beans.But I don’t know how I have tried to add the proprity Connection to the managed Bean but I don’t know if that is the good solution and if yes it dosen’t work for me:( ,there are my classess :

**1/Class Connectionx**
public class Connectionx implements java.io.Serializable{
public Connection cx=null;
public Statement st;
public Connectionx() {}
public Connection Connx()
{ 
System.out.println("enregister le driver");
    try {
        Class.forName("com.mysql.jdbc.Driver");

    }
    catch( Exception ex )
            {
            System.err.println("Erreur lors du chargement du              driver"+ex.getMessage() );

            }
    try {
        /** Connection  */
         cx =  (Connection) DriverManager.getConnection( "jdbc:mysql://localhost/jiradb","root","root" );

        System.out.println("conexion reussite ");

            }
            catch( SQLException ex )
            {
            System. err. println( "Erreur lors de la connexion à la       baseeeeee" );

            }
  return cx;
}
public void deConnx(Connection cx) throws SQLException{

cx.close();
System. err. println( "deconnection");   
 }
 }

2/Class BeanTools

 public class BeanTools implements java.io.Serializable {

 /***************selectonemenu***********************/   
 private List<SelectItem> mesElements;
 private  String maValeur;
 public String[] favNumber1 ; //checkbox
 public PreparedStatement st;
 public Connectionx cx = new Connectionx();
 public Connection con = (Connection)cx.Connx();

 /**************checkbox***************/
  public BeanTools() {
  }

   public String getMaValeur() {
    return maValeur;
  }

   public void setMaValeur(String maValeur) {
    this.maValeur = maValeur;
   }

   public String[] getFavNumber1() {
    return favNumber1;
    }

   public void setFavNumber1(String[] favNumber1) {
    this.favNumber1 = favNumber1;
  }

   public String getFavNumber1InString() {

    return Arrays.toString(favNumber1);
}


    public String getFavNumber1onebyone()
    {  String Val =null;
    for(int i=0;i<favNumber1.length;i++)
    {
    if (favNumber1[i].equals("1"))
        System.out.println("priority checked");
    if (favNumber1[i].equals("2"))
        System.out.println("project checked");
    if (favNumber1[i].equals("3"))
   System.out.println("Month checked");

    }

    return Val;
    }


   public Iterable<String> remplireItem() throws ClassNotFoundException, SQLException
  {

   String sql;
   sql ="select issuestatus.pname from issuestatus;";
   System.out.println("sql");
   st=(PreparedStatement) con.prepareStatement(sql);
   ResultSet rs1 = st.executeQuery();System.out.println("execute");

   String val;
   ArrayList<String> list = new ArrayList<String>();
   while(rs1.next())
    {
      val= rs1.getString("pname");
      System.out.println(val);
      list.add(nbb);
      System.out.println("list"+list.toString());
    }
     return list;
    }


    public List<SelectItem> getMesElements() throws SQLException,ClassNotFoundException {

   if (mesElements == null) {
   mesElements = new ArrayList<SelectItem>();
   for (String val : remplireItem()) {
   mesElements.add(new SelectItem(val));
   }
   }
     return mesElements;
   }

3/class NumberOfIssue

public class NumberOfIssue implements java.io.Serializable{

public  String numberIssue;
private  String maValeur;
public Connectionx cx = new Connectionx();
public Connection con = (Connection)cx.Connx();
public PreparedStatement st;


public NumberOfIssue() {
}


   public String getMaValeur() {
    return maValeur;
}

public void setMaValeur(String maValeur) {
    this.maValeur = maValeur;
}

public String getNumberIssue() throws SQLException
{
//Connection con
BeanTools beTools=new BeanTools();
System.out.println("beTools.maValeur");
String sql;
sql ="select count(OS_CURRENTSTEP.entry_id) as nbissue     ,project.pname,priority.pname,issuetype.pname from OS_CURRENTSTEP,jiraissue,issuestatus,issuetype,project,resolution,customfield ,customfieldvalue,priority   where OS_CURRENTSTEP.entry_id = jiraissue.id  and jiraissue.priority=priority.id  and jiraissue.issuestatus=issuestatus.id and issuestatus.pname="+maValeur+" and jiraissue.issuetype=issuetype.id and jiraissue.project=project.id   and resolution.id=jiraissue.resolution  and resolution.pname='Fixed'  Group By project.pname,priority.pname,issuetype.pname;";

st= (PreparedStatement) con.prepareStatement(sql); 

ResultSet rs1 = st.executeQuery();

while(rs1.next())
{
 numberIssue=  rs1.getString(1);
 String strissue2=  rs1.getString(2);
 String strissue3=  rs1.getString(3);
 System.out.println("nb issue  "+numberIssue.toString()+"  ||project      "+strissue2.toString()+"  ||proiority  "+strissue3.toString());

}
return numberIssue;
}

}

4/Managed Bean

<managed-bean>
<managed-bean-name>Connectionx</managed-bean-name>
<managed-bean-class>KPIs.Connectionx</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

<managed-bean>
<managed-bean-name>BeanTools</managed-bean-name>
<managed-bean-class>KPIs.BeanTools</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>cx</property-name>
<property-class>java.sql.Connection</property-class>
<value>#{Connectionx.cx}</value>
</managed-property>
</managed-bean>

<managed-bean>
<managed-bean-name>NumberOfIssue</managed-bean-name>
<managed-bean-class>KPIs.NumberOfIssue</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>maValeur</property-name>
<property-class>java.lang.String</property-class>
<value>#{BeanTools.maValeur}</value>
</managed-property>
<managed-property>
<property-name>cx</property-name>
<property-class>java.sql.Connection</property-class>
<value>#{Connectionx.cx}</value>
</managed-property>
</managed-bean>

<navigation-rule>
<from-view-id>/welcomeJSF.jsp</from-view-id>
<navigation-case>
<from-outcome>submit</from-outcome>
<to-view-id>/Result.jsp</to-view-id> 
</navigation-case>
</navigation-rule>
</faces-config>

THE STACKTRACE

com.sun.faces.mgbean.ManagedBeanCreationException: Impossible de créer le bean géré    BeanTools.  Les problèmes suivants ont été détectés :
 - La propriété cx du bean géré BeanTools nexiste pas.
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:265)
at                                        com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71)
at org.apache.el.parser.AstValue.getValue(AstValue.java:147)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:106)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at com.sun.faces.renderkit.html_basic.MenuRenderer.getCurrentSelectedValues(MenuRenderer.java:648)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:749)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:844)
at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:298)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
at com.sun.faces.application.view.JspViewHandlingStrategy.doRenderView(JspViewHandlingStrategy.java:431)
at com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:233)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:38:47+00:00Added an answer on May 22, 2026 at 11:38 pm

    Use a connection pool like commons-dbcp.

    By the way this kind of code

    "select count(OS_CURRENTSTEP.entry_id) as nbissue  [.. snip ...]
    and issuestatus.pname="+maValeur+" and jiraissue.issuetype=issuetype.id
    [... snip ...] and resolution.pname='Fixed'  Group By     
    project.pname,priority.pname,issuetype.pname;";
    

    is vulnerable to SQL injection, you should replace the maValeur variable with a parameter (see http://en.wikipedia.org/wiki/SQL_injection#Parameterized_statements)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement my persitent classes using interfaces. I have created the
I have created some extra functionality on my Linq-to-SQL classes to make things easier
Say I have two classes created work and workItem. CWorker *work = new CWorker();
I have created custom MembershipUser, MembershipProvider and RolePrivoder classes. These all work and I
After I have created a serious bunch of classes (with initialize methods), I am
I have created a debugger visualizer in VS2008. There are two classes i've made,
I'm building an app around Vici Coolstorage (asp.net version). I have my classes created
I have several classes, that all derives from SuperClass. When the classes are created,
I have a collection of classes that inherit from an abstract class I created.
Can JavaScript classes/objects have constructors? How are they created?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.