1 2 3 Previous Next 30 Replies Latest reply on Nov 6, 2004 3:06 AM by 807575 Go to original post
      • 15. Re: Conversion Error Occurred
        i am also having a Conversion Error occured similar to this. However, my error is not cuased by bound fields. I can bind fields just fine, as long as I only have one table in a RowSet. What I did was JOINed 3 tables in one RowSet. SELECT statements work fine, but I can't update. that damn Conversion Error is in my way. what is going on? i actually made a separate thread for this about half an hour ago. please help! thanks!
        • 16. Re: Conversion Error Occurred
          One other quick note on my example above:

          Set the listbox to 'auto-submit on change' and the Conversion Error Occurred message will pop up every time you select a different row in the list (a different Master record). Reselect the original master record in the listbox and the messages will go away.

          I just created a simple application using a SQL Server database. This is the code from page1.java:

          public class Page1 extends AbstractPageBean {
          // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">

          private int __placeholder;

          private HtmlForm form1 = new HtmlForm();

          public HtmlForm getForm1() {
          return form1;

          public void setForm1(HtmlForm hf) {
          this.form1 = hf;

          private HtmlSelectOneListbox listbox1 = new HtmlSelectOneListbox();

          public HtmlSelectOneListbox getListbox1() {
          return listbox1;

          public void setListbox1(HtmlSelectOneListbox hsol) {
          this.listbox1 = hsol;

          private UISelectItems listbox1SelectItems = new UISelectItems();

          public UISelectItems getListbox1SelectItems() {
          return listbox1SelectItems;

          public void setListbox1SelectItems(UISelectItems uisi) {
          this.listbox1SelectItems = uisi;

          private JdbcRowSetXImpl triprequestRowSet = new JdbcRowSetXImpl();

          public JdbcRowSetXImpl getTriprequestRowSet() {
          return triprequestRowSet;

          public void setTriprequestRowSet(JdbcRowSetXImpl jrsxi) {
          this.triprequestRowSet = jrsxi;

          private IntegerConverter listbox1Converter = new IntegerConverter();

          public IntegerConverter getListbox1Converter() {
          return listbox1Converter;

          public void setListbox1Converter(IntegerConverter ic) {
          this.listbox1Converter = ic;

          private HtmlOutputText outputText1 = new HtmlOutputText();

          public HtmlOutputText getOutputText1() {
          return outputText1;

          public void setOutputText1(HtmlOutputText hot) {
          this.outputText1 = hot;

          private HtmlOutputText outputText2 = new HtmlOutputText();

          public HtmlOutputText getOutputText2() {
          return outputText2;

          public void setOutputText2(HtmlOutputText hot) {
          this.outputText2 = hot;

          private JdbcRowSetXImpl tripsegmentRowSet = new JdbcRowSetXImpl();

          public JdbcRowSetXImpl getTripsegmentRowSet() {
          return tripsegmentRowSet;

          public void setTripsegmentRowSet(JdbcRowSetXImpl jrsxi) {
          this.tripsegmentRowSet = jrsxi;

          private HtmlMessage inlineMessage1 = new HtmlMessage();

          public HtmlMessage getInlineMessage1() {
          return inlineMessage1;

          public void setInlineMessage1(HtmlMessage hm) {
          this.inlineMessage1 = hm;

          private HtmlOutputText outputText3 = new HtmlOutputText();

          public HtmlOutputText getOutputText3() {
          return outputText3;

          public void setOutputText3(HtmlOutputText hot) {
          this.outputText3 = hot;

          private HtmlInputText textField1 = new HtmlInputText();

          public HtmlInputText getTextField1() {
          return textField1;

          public void setTextField1(HtmlInputText hit) {
          this.textField1 = hit;

          private HtmlMessage inlineMessage2 = new HtmlMessage();

          public HtmlMessage getInlineMessage2() {
          return inlineMessage2;

          public void setInlineMessage2(HtmlMessage hm) {
          this.inlineMessage2 = hm;

          private HtmlOutputText outputText4 = new HtmlOutputText();

          public HtmlOutputText getOutputText4() {
          return outputText4;

          public void setOutputText4(HtmlOutputText hot) {
          this.outputText4 = hot;

          private HtmlInputText textField2 = new HtmlInputText();

          public HtmlInputText getTextField2() {
          return textField2;

          public void setTextField2(HtmlInputText hit) {
          this.textField2 = hit;

          private HtmlMessage inlineMessage3 = new HtmlMessage();

          public HtmlMessage getInlineMessage3() {
          return inlineMessage3;

          public void setInlineMessage3(HtmlMessage hm) {
          this.inlineMessage3 = hm;

          private HtmlOutputText outputText5 = new HtmlOutputText();

          public HtmlOutputText getOutputText5() {
          return outputText5;

          public void setOutputText5(HtmlOutputText hot) {
          this.outputText5 = hot;

          private HtmlInputTextarea textArea1 = new HtmlInputTextarea();

          public HtmlInputTextarea getTextArea1() {
          return textArea1;

          public void setTextArea1(HtmlInputTextarea hit) {
          this.textArea1 = hit;

          private HtmlMessage inlineMessage4 = new HtmlMessage();

          public HtmlMessage getInlineMessage4() {
          return inlineMessage4;

          public void setInlineMessage4(HtmlMessage hm) {
          this.inlineMessage4 = hm;

          private HtmlCommandButton button1 = new HtmlCommandButton();

          public HtmlCommandButton getButton1() {
          return button1;

          public void setButton1(HtmlCommandButton hcb) {
          this.button1 = hcb;
          // </editor-fold>
          public Page1() {
          // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
          try {
          triprequestRowSet.setCommand("SELECT ALL dbo.TripRequest.RequestID, dbo.TripRequest.RequestStatusID, dbo.TripRequest.PreparedByID, dbo.TripRequest.TripTypeID, dbo.TripRequest.BillToDept, dbo.TripRequest.RequestDate, dbo.TripRequest.ShortDescription, dbo.TripRequest.PeopleAndCompany, dbo.TripRequest.Benefit, dbo.TripRequest.Comments FROM dbo.TripRequest");
          tripsegmentRowSet.setCommand("SELECT ALL dbo.TripSegment.TripSegmentID, dbo.TripSegment.RequestID, dbo.TripSegment.TravelDate, dbo.TripSegment.TravelFrom, dbo.TripSegment.TravelTo, dbo.TripSegment.AirlineID, dbo.TripSegment.FlightNbr, dbo.TripSegment.FlightTime, dbo.TripSegment.RentalCarAgencyID, dbo.TripSegment.RentalCarSizeID, dbo.TripSegment.Hotel FROM dbo.TripSegment WHERE dbo.TripSegment.RequestID=?");
          } catch (Exception e) {
          log("Page1 Initialization Failure", e);
          throw e instanceof javax.faces.FacesException ? (FacesException) e : new FacesException(e);
          // </editor-fold>
          // Additional user provided initialization code
          try {
          tripsegmentRowSet.setObject(1, triprequestRowSet.getObject("REQUESTID"));
          } catch (Exception ex) {
          throw new FacesException(ex);
          } // end try catch

          protected webapplication4.ApplicationBean1 getApplicationBean1() {
          return (webapplication4.ApplicationBean1)getBean("ApplicationBean1");

          protected webapplication4.SessionBean1 getSessionBean1() {
          return (webapplication4.SessionBean1)getBean("SessionBean1");

          * Bean cleanup.
          protected void afterRenderResponse() {

          public void listbox1_processValueChange(ValueChangeEvent vce) {
          // User event code here...
          try {
          tripsegmentRowSet.setObject(1, listbox1.getValue());
          } catch (Exception ex) {
          throw new FacesException(ex);
          } // end try catch
          • 17. Re: Conversion Error Occurred
            Just fyi, I am going to work w/Haroon first to better understand what's going on here (you are all running into something... but it works fine for me.... and for our QA folks.... so there's something missing from the equation somewhere).

            So hang in there and we'll figure it out....

            • 18. Re: Conversion Error Occurred
              V, nice to hear you're working on this. Thanks. It is a show stopper.

              I did find one workaround, though: I just changed all my fields to read only and that got rid of the problem. But, gosh, that kind of nulifies the idea of a web application and turns it into a simple web page, huh?

              FYI, here's my configuration data:

              Windows XP version 5.1 service pack 1 with all the latest patches.
              Pentium 4 2GHz processor
              1 GB memory

              Networked Server:
              MS 2000 Server
              SQL Server 2000 version 8.00.194, Language English US, 1 processor, Security:Authentication: SQL Server and Windows

              Studio Creator:
              version 2004Q2 with all the latest updates (build 040621)
              Sun Java 1.4.2_04
              VM 1.4.2_04-b05
              DB URL: jdbc:sun:sqlserver://2000Dev1:1433;DatabaseName=travelRequest_dev;SelectMethod=cursor
              DB Driver: com.sun.sql.jdbc.sqlserver.SQLServerDriver

              Let me know if I can give you any more info to solve this.
              • 19. Re: Conversion Error Occurred
                Hi all!

                Ok - I worked w/Haroon this morning andI think I understand what's going on here! Let me try to explain.... first I'll summarize the scenario at hand:
                Start w/page with 3 components:
                - textfield
                - button
                - message list

                Add a rowset to the page, and bind the textfield to one of the columns in that rowset

                Now run. The data shows in the textfield, but when I type something else into the textfield and click the button, a conversion error is shown in the message list.

                I haven't added a converter or anything - what's going on? Shouldn't this work?
                Answer : No, but it would be nice if you got a better error message. Now I'll try to explain why!

                Textfield is a JSF input component (as is a dropdown, etc). By default, when a page is "submitted" (via button click), in the JSF lifecycle they will inherently go through validation and conversion.

                In this case, the textfield is bound to a rowset which by default is set to CONCUR_READ_ONLY (the default concurrency property). So it cannot accept changes (because the rowset won't allow it), and hence an error was thrown durring the conversion stage. Granted, If it had given you an error stack that included something like "rowset does not allow current operation" that would have been helpful :) I'll see if we can do something there (might be deep inside JSF, not sure yet).

                So, what do you need to do to get it to work? You have 2 choices:

                1) Change the concurrency property to CONCUR_UPDATABLE and then all will be fine

                2) Set the immediate property on the button so that it will bypass the conversion/validation phases. For example, you will see that in the AppModel sample, we set the immediate property on the cancel buttons because really, who cares if the stuff isn't valid etc - we're just gonna throw it away anyway. But you should do this only when you are sure you don't want ANY of the validation/conversion to occur for the page. In this scenario, I think it was correctly refusing to update the values in the rowset (although it didn't give a clear enough error message) - so that's a feature :)

                Let me know if you have more q's!
                • 20. Re: Conversion Error Occurred
                  v, I tried doing exactly as you outlined, but it doesn't fix the problem.

                  I built an app with a text field, a button and a message list. I bound the text field to a Microsoft SQL Server database table. I set the datasource to CONCUR_UPDATEABLE.

                  If I modify the value in the text field and press the button, I still get a "textField1 Conversion error occurred" message. If I remove my changes and put the field back to its original value the error message goes away.

                  I tried this using three different field types, Integer (with an Integer Converter), Char and VarChar. All of them fail the same way.

                  I can't get past this problem.

                  FYI, I also tried the same thing using the embedded Poinbase DB. That runs fine. I do not get the conversion error message. AND, get this: even if I leave the datasource set to CONCUR_READ_ONLY I do not get the error message.

                  This is all done using the standard datasource driver classes that come with JSC.

                  The JSC Components are behaving differently based on the underlying database (SQL Server or Pointbase) that the fields are bound to.

                  I've included the .java code and my system configuration on previous messages on this thread if you need to see them.

                  Please let me know if I can give you more information on this.
                  • 21. Re: Conversion Error Occurred
                    PROBLEM SOLVED

                    I stopped using the SQL Server driver that came with Creator.

                    Instead, I switched to using the jtds driver from sourceForge and the problem went away.
                    • 22. Re: Conversion Error Occurred
                      Thanks SB for posting your solution - I will ask QA to double check your scenario on SQL Server with our included drivers (Haroon and I were using Oracle for our verification).

                      Does that driver work at design time as well (server navigator, query editor, etc)? That would be nice to know.

                      So we have the complete picture, could you please post the sql to create your sql server table you were having trouble with so we are sure we're using the exact same datatypes for our testing?

                      Glad you're back in business!
                      • 23. Re: Conversion Error Occurred
                        I tried to recreate the problem using SQLServer that SueBob mentioned, and could not.
                        It worked fine for me.

                        When concurrency is: CONCUR_READABLE

                        I get the conversion error.

                        When the concurrency is: CONCUR_UPDATEABLE

                        I don't get the conversion error.

                        That is how it should be, I think, except for a more user friendly message.

                        Using JSC drivers.
                        • 24. Re: Conversion Error Occurred
                          Also see the tutorial "About DataTable Components" which will show you more "how to"s

                          • 25. Re: Conversion Error Occurred
                            I from Costa Rica, and my problem is the same "Conversion Error Occured".
                            I'm using an Oracle Database (with driver ojdbc.jar). I have one page using a datatable which presents no problem with resultset's, I mean, I can do many queries to the database and the datatable works very good. But I have other page with textfields bind to database, when I do the first query The textfield works good and their values are from the database(that it's very good) BUT qhen I try to do other query with other criteria and press the SUBMIT button I see in the page the next text: "txt_num_person:Conversion Error Occurred".
                            So I tried deleting some textfields and I put some OutputText and the error goes away.
                            Now my page is working very good with this change, but I need to put in the page the option to insert, delete, etc so it's means that I have to put textfields instead of outputText, and if I do that the error will come back to me!.

                            I need some help, please.
                            My e-mail is: wendy@decsacr.com

                            • 26. Re: Conversion Error Occurred
                              Hi Wendy,

                              First let's figure out which textfield is the problem.

                              Add MessageComponents next to each textfield, and associate them together (see the About Message Components tutorial for details at http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp )

                              This will show you which textfield(s) are having the problem.

                              Then you will need to examine what type the database is expecting - to do this, go to the server navigator, browse to the table you are binding to, and click on the columns - look at the property sheet. This will tell you the type it is expecting.

                              Finally, go back to the textfields and associate the appropriate converter - see the table below:
                              JDBC Type (which we call SQL Type) --> Java Type:
                              CHAR --> java.lang.String
                              VARCHAR --> java.lang.String
                              LONGVARCHAR --> java.lang.String
                              NUMERIC --> java.math.BigDecimal
                              DECIMAL --> java.math.BigDecimal
                              BIT --> boolean
                              BOOLEAN --> boolean
                              TINYINT --> byte
                              SMALLINT --> short
                              INTEGER --> int
                              BIGINT --> long
                              REAL --> float
                              FLOAT --> double
                              DOUBLE --> double
                              BINARY --> byte[]
                              VARBINARY --> byte[]
                              LONGVARBINARY --> byte[]
                              DATE --> java.sql.Date
                              TIME --> java.sql.Time
                              TIMESTAMP --> java.sql.Timestamp
                              CLOB --> java.sql.Clob
                              BLOB --> java.sql.Blob
                              ARRAY --> java.sql.Array
                              DISTINCT --> (mapping of underlying type)
                              STRUCT --> java.sql.Struct
                              REF --> java.sql.Ref
                              DATALINK --> java.net.URL
                              JAVA_OBJECT --> (underlying Java class)

                              Source: JDBC 3.0 Specification, Appendix B

                              • 27. Re: Conversion Error Occurred
                                Hi v,

                                Thanks for your help.

                                Actually I had tried with the converter type, but it wasn't work to me. When I tried with this way its happen the next:

                                1. I have a textfield which it isn't bind to a database. Because in this text will be the criteria for the query.
                                2. So, when the user put some values in that textfield and press SUBMIT button appears the correct result, its means that I don't have problem with this.
                                3. BUT when the user try to do an other query (with other criteria) press the CLEAN button. This button has the function to "clean" all the textfields that were full with the previous query. The line is:

                                textfield1.setValue(" ");

                                When the page try to do this, in that moment the error come.

                                I don know if you can understand me?

                                But it is so weird, because when I put the OutputText instead of Textfields my page works very good!

                                Please, Help me!!!!


                                Costa Rica
                                • 28. Re: Conversion Error Occurred
                                  Ah - I think you want to set the "immediate" property on the clean button - this will make it so JSF will skip the validation/conversion parts of the lifecycle (which is attempting to convert your settings and failing).

                                  You would also typically want to do this on a "cancel" button as well, since if the user is cancelling an action there's no reason to do any validation/conversion....

                                  I think that should do it!
                                  • 29. Re: Conversion Error Occurred
                                    I Guess I�ve got the same problem, till now Does anybody solve this problem ?