3 Replies Latest reply on Oct 3, 2003 7:01 PM by eric g

    java query question

    riddler3479 Newbie

      I am trying to create a query in java.

      I have used the following syntax to create queries:

      query = "SELECT * FROM TABLE WHERE VALUE = ?";

      PreparedStatement ps =


      This will not work on jboss. Instead, I have to change all of the queries to actually have the values in the query. Does anyone know why this occurs?

      query = "SELECT * FROM TABLE WHERE VALUE = '" + somValue + "'";


        • 1. Re: java query question
          riddler3479 Newbie

          fixed to db driver issues

          • 2. Re: java query question
            caprieto Newbie

            The value pass to is a String? may need use quotes.

            • 3. Re: java query question and example on how to use ejbSelect
              eric g Newbie


              Just a suggestion only, why don't you used entity CMP to managed your sql transaction and used EJB-QL language, to perform SQL query .

              Just to help you to get started , in your entitybean do not specify finder used ejbselect instead ,as it prove much more flexible.

              All the jboss book in the market just could not tell a simple thing on how to make use of ejbSelect

              here are my suggestions.

              1. specify the collection to make use of ejeSelect like eg given ejbSelectMat()

              in your entity bean

              public abstract Collection ejbSelectMat() throws FinderException;

              2. specify the the query method in your entity bean to get the result through home interface QueryMat where ejbHome is a must

              public Collection ejbHomeQueryMat() throws FinderException {
              try {
              return ejbSelectMat();
              } catch (Exception e) {
              return null;

              3. in the ejb-jar.xml files

              <ejb-ql><![CDATA[SELECT cmas.code FROM codemaster cmas where cmas.ctype='MAT']]></ejb-ql>

              4. the above if translated to plain SQL query would equivalent to

              [select code form codemaster where ctype="MAT"]

              wouldn't it is much simpler to manage through CMP 2.0
              using ejb 2 , the order by clause is only available in ejb 2.1 or some other J2ee server like resin for example but not jboss .