4 Replies Latest reply: Mar 7, 2013 11:39 PM by user575089 RSS

    batch update  problem

    user575089
      There is no constructor in java.sql.BatchUpdateException............How do I send a error message ?






      I am trying to do this my DAO class..

      new java.sql.BatchUpdateException("Duplicate entry not allowed") // This does not compile because it does not has such constructor.


      What is the alternative I can do ?
        • 1. Re: batch update  problem
          EJP
          Why are you throwing SQLExceptions yourself? Only the JDBC driver is supposed to do that.
          • 2. Re: batch update  problem
            user575089
            I have a unique key ( not primary key) at a database column. I want user not enter any duplicate entry in the UI.

            I want to catch exception during update and want to show user a error message for not entering any duplicate entry.

            problem is ...how do I throw batchupdatexception with this error message ? there is no constructor in batchupdatexception . What is the solution ?

            Is there any alternative solution for this problem ?
            • 3. Re: batch update  problem
              rp0428
              >
              There is no constructor in java.sql.BatchUpdateException............How do I send a error message ?
              >
              Really? Last time I checked every class in Java has a constructor.

              You might want to check the API doc again - it shows 10 constructors
              http://docs.oracle.com/javase/6/docs/api/java/sql/BatchUpdateException.html
              >
              new java.sql.BatchUpdateException("Duplicate entry not allowed") // This does not compile because it does not has such constructor.
              >
              Now that is certainly true - it does not have a construction that takes a single String argument.
              >
              I am trying to do this my DAO class..
              >
              Well - DON'T DO THAT!

              Create your own exception class, create it with a constructor that takes a single String argument and then throw it anytime you want to.
              • 4. Re: batch update  problem
                user575089
                Thanks . It was helpful.