Customer Validation Inside a Servlet...

I am having some trouble getting the code correct to see whether the customer exists in the database, and if so, not inserting a new record. Otherwise, I just want to update the orders. Any suggestions would be greatly appreciated, I am new to Java! here is a pc of the code that is not working correctly. Thanks....
String firstname = req.getParameter("firstname");
String lastname = req.getParameter("lastname");
boolean isCustid =false;
String queryFirstLast = "SELECT firstname, lastname from CUSTOMERS";
ResultSet rs = executeQuery(queryFirstLast);
while(isCustId==false){
rs.next();
if(!rs.getString.equals(firstname)&(!rs.getString.equals(lastname))){
String insertNewCust = "INSERT INTO CUSTOMERS("firstname", "lastname", etc...
VALUES("+firstname+", "+lastname+" etc...
}else{
update order code...
isCustid =true;
Again, I would appreciate any comments...Thank you!

Hi
Use something like this:
PreparedStatement pStmt = con.prepareStatement("SELECT * FROM TABLE WHERE Firstname =? AND Lastname =?");
  pStmt.setString(1, firstname);
  pStmt.setString(2, lastname);
  ResultSet rs = pStmt.executeQuery();
  //System.out.println("sql : "+pStmt);
  try{
  if(!rs.next()){
     System.out.println("User not found");
  else do{
     System.out.println("User found");
  }while (rs.next());Andreas

Similar Messages

  • Custom validation Messages printed more than once :-(

    Hi,
    I have added a Custom Validator to a drop down list box (h:selectOneMenu) and for a text field. and i bound these form elements to the corresponding UIComponent Object in the becking bean. The backing bean is in session scope I have a link which will forward to a different page and i disabled the validation on this link by setting immediate as true.
    But when the user clicks the command link goes second page and then comes back to the first page and click the submit button, the validation error occurs. But to my surprise i am getting the same Validation error message printed twice or thrice (as when we are going to the second page and then comes back and submits).
    If I am correct the Validator corresponding to the component keeps the old error state and then add the new error state.
    I tried to remove one FacesMessage object which i got from Iterator of FacesContext.getMessages() and then tried. but hence also i was getting the same result.
    When i looked at the log, i foud my validator class being invoked twoce (or thrice depending upon the no. of times i went to the secoond page).
    Can you please help me out from this problem?
    Thanking you,
    Sudheesh

    If it is indeed 1.1, I'd recommend trying 1.1_02 [1] and trying again.
    [1] https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList?folderID=5225&expandFolder=5225&folderID=5220

  • Custom Validation in ESS Edit Screen

    All,
    We have a requirement in ESS Address screens that all country users should key in only English Data. We are in SAP ESS SP12 and all the Address Components are in WD Java. The validation on all the address screen fields for this requiement has to be handled and give an error message back to the user.
    The Options that I Checked out were:
    1) Handling the Validation through BADI HRPAD00INFTYUI or HRPAD00INFTYBL.
    2) Handling the validation in WD Java layer inside the country spoecific components isConsistent method of the Detail View Component controller
    Which is the best place (ABAP or JAVA) to handle Custom validations on the Edit Screen and give back message to the user? Please suggest if any other better options are available other than the above mentioned ones.
    Regards,
    Nagarajan.

    Hi,
    Both are doable if you are good in java and have NWDI ,handling validations in the wd java layer is easy. If you are good in ABAP you can handle in ABAP.It depends on how you write your code, if you do validations in java and if your validation fails you can show errors to user right away which will reduce your call to backend at isconsitent method for checking the errors.
    Thanks,
    pkv

  • Custom Validation Routine not getting triggered

    Hi,
    I need some information regarding the Validation Routines that is maintained in SPRO.
    I created a validation routine and activated it. And also I maintained all the configurations needed. But when I create an ASN in VL60, the program control is not going inside the validation routine that I created.
    When I checked the program /SPE/RTS, I found that it contains all the SAP Std validation routines except the routine that I created. I believe that an entry need to be created automatically in the program /SPE/RTS when activarte my custom validation routine, which is not happening.
    Does any one else has faced this issue before? Thanks a lot in advance.....
    Thanks & Regards
    Sreeraj Pulickal

    Vinod,
    I do have a separate client for testing and I had moved all the changes from DEV to Testing client. But since no entry has been created in program /SPE/RTS for my custom validation routine in DEV, there is point in moving all the changes. The validation routine won't get triggered.
    So I created an implicit enhancement in /SPE/RTS to include my validation routine. I'm not sure whether this is the right approach, but it solved my problem.
    Thanks
    Sreeraj.

  • Perform custom validation on invoices created via iSupplier portal in R12

    Hello,
    It seems that since R12, invoices created on iSupplier portal are no longer loaded via Payables open interface tables (while ASBN's still are). It is nice that they are loaded immediately but now we do not have any way to perform custom validation that we normally do via AP_INTERFACE_WORKFLOW_PKG.do_custom_validation procedure.
    Is there any way to modify how iSupplier portal inserts Invoice data into AP tables? In particular we would like to choose specific document category for certain suppliers.
    Many thanks in advance,
    Kamil

    Hi Friends,
    Apologies to have put this in SCM-Costing Category. I just posted the same thing in Financials Category.
    Please ignore this, if found irrelevant under this category.
    Thanks,
    AAR

  • Problem with custom validated data types using domain on 11g

    Hi,
    I ' m on a migration process from 10 to 11 and I notice that a custom domain didn't work correctly anymore
    to be more specific every time that I was submiting a page a was getting an error cannot convert from myclass to oracle.jbo.domain.String
    I search the forum and I saw a similar problem
    Cannot convert type class java.lang.String to class oracle.jbo.domain.Clob
    at which Frank says that it is a known bug and suggests a work around.
    I use the workaround and it worked but some more issues came up:
    1. If the validation fails I get the error that I throw at the validate method not in a popup with just my message
    but in the whole window with the whole error stack, meaning that my custom validation is not handled like native ADF validation errors by
    the framework (at 10.1.3.4 worked OK)
    2 If i dont give a value at the attribute in the validation phase mdata variable is not null but is length is zero (at 10.1.3.4 its value was null)
    public class AFM implements DomainInterface, Serializable {
    public AFM(String val) {
    mData = new String(val);
    validate();
    private String mData;
    protected void validate() {
    // ### Implement custom domain validation logic here. ###
    mData==null // returns false
    mData.length()==0 // returns true
    3. Can i force validation only for new or updated values? I saw that the validation process is taking place every time a row is fetched.
    This is not only a performance issue, the bigger problem is that if a fetched from the DB value fails the validation an error is return but the
    user cannot change the value to correct it.
    TIA
    Tilemahos

    since i don't get any answer I wonder if i should have use a more provocative title like
    "custom domains in 11g don't work"
    is it true?
    Tilemahos

  • Custom Validator Class not found in Class Path

    I have developed a custom validator class for User Self Registration request. However, when OIM is unable to find the custom validator class and generates teh following error:
    [oracle.iam.platform.pluginframework] [tid: [ACTIVE].ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: oiminternal] [ecid: 76584c4849877d50:-45bb4068:13c8294bd72:-8000-0000000000001236,0] [SRC_CLASS: oracle.iam.platform.pluginframework.InternalStore] [APP: oim#11.1.1.3.0] [SRC_METHOD: getPluginInstance] Not able to load class com.infotech.tra.CustomValidator.SelfRegisterUserCustomValidator from classpath
    At what path should the jar file be placed?
    UZ

    I am running the plugin registration utility but it generates the error mentioned below. I have verified the structure of my zip file and the structure of zip file is:
    -> SelfRegisterUserCustomValidator.zip
    ->Plugin.xml
    ->/lib/SelfRegisterUserCustomValidator.jar
    ->/resources/
    Following our contents of plugin.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <oimplugins>
    <plugins pluginpoint="oracle.iam.request.plugins.RequestDataValidator">
    <plugin pluginclass= "com.infotech.tra.CustomValidator.SelfRegisterUserCustomValidator" version="1.0.0" name="SelfRegisterUserCustomValidator">
    </plugin>
    </plugins>
    </oimplugins>
    Following is the error being generated:
    Enter name (complete file name with path) of the plugin file:
    /u01/oracle/Middleware/Oracle_IDM1/server/plugin_utility/SelfRegisterUserCustomValidator.zip
    [java] Java Result: 1
    [echo] Exception in thread "main" java.lang.NoClassDefFoundError: oracle/iam/platformservice/utils/PluginUtility
    [echo] Caused by: java.lang.ClassNotFoundException: oracle.iam.platformservice.utils.PluginUtility
    [echo] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    [echo] at java.security.AccessController.doPrivileged(Native Method)
    [echo] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    [echo] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    [echo] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    [echo] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    [echo] Could not find the main class: oracle.iam.platformservice.utils.PluginUtility. Program will exit.

  • How do you create custom validation rule in WS 9.2?!?!?!

    Hello,
    I am using Workshop 9.2. I created a page flow, and want to do some form validations.
    I saw the simple 9.2 example, but it is only good for very basic validation, what if you have to validate the form field against a database, must you write a custom validation rule? HOW would you do this in 9.2 so that will still stay with the workshop/netui paradigm?
    http://beehive.apache.org/docs/1.0.1/netui/validation.html
    Keith

    Hi Keith,
    Staying within the declarative validation framework the answer is probably that you do need to write a custom validation rule and refer to it using the @Jpf.ValidateCustomRule annotation.
    The NetUI Annotation Reference shows how the Struts validations are supported via the framework.
    http://beehive.apache.org/docs/1.0.1/netui/annotations/pageflow_annotations.html
    Specifically, if you look through the @Jpf.Validate* annotations, while most of these are "canned" common validations, there are a few that are more open-ended, such as @Jpf.ValidateMask and @Jpf.ValidateValidWhen.
    Those two let you write the validation logic in the annotation while @Jpf.ValidateCustomeRule only refers to a custom rule in the struts validator file.
    In any case, there is a validation rule editor which should help in authoring and managing the annotations. In the Page Flow Explorer or Page Flow Editor just right click on the action or form bean bean of interest and choose Validation Rules and the appropriate scope.
    I hope that's of some use,
    Troy

  • Custom Validator for a Custom Component

    I am having troubling passing values from my custom component
    to my custom validator (via a model). For some reason when the
    validate() function is called for the validator the value parameter
    passed to the validator is not showing the value from my custom
    component.
    I have attached some example code to illustrate.
    Here is my model:
    <mx:Model id="myModel">
    <root>
    <mod>
    <name>{myTextInput.text}</name>
    <date>{myDateField.selectedDate.getTime()}</date>
    <length>{myComp.getLength()}</length>
    </mod>
    </root>
    </mx:Model>
    When I update the value of myTextInput or myDateField the
    model (as sent to the validator) shows the correct value. When I
    change the value of myComp the change is not reflected.
    Is there a particular event (or something) being dispatched
    in the other components to cause the model to get the new value
    that I need to include in my custom component? I am pretty stuck
    and would appreciate any help.
    Many thanks

    Does myComp extend EventDispatcher (or any class which does)?
    You need to flag the getLength() function as bindable and to
    dispatch an event:
    [Bindable('getLengthChange")]
    public function getLength() : Number
    // does whatever it does
    When you update myComp have it dispatchEvent( new
    Event("getLengthChange") ) and I think it will work.

  • How do i create a single instance of a class inside a servlet ?

    how do i create a single instance of a class inside a servlet ?
    public void doGet(HttpServletRequest request,HttpServletResponseresponse) throws ServletException, IOException {
    // call a class here. this class should create only single instance, //though we know servlet are multithreaded. if, at any time 10 user comes //and access this servlet still there would one and only one instance of //that class.
    How do i make my class ? class is supposed to write some info to text file.

    i have a class MyClass. this class creates a thread.
    i just want to run MyClass only once in my servlet. i am afriad, if there are 10 users access this servlet ,then 10 Myclass instance wouldbe created. i just want to avoid this. i want to make only one instance of this class.
    How do i do ?
    they have this code in the link you provided.
    public class SingletonObject
      private SingletonObject()
        // no code req'd
      public static SingletonObject getSingletonObject()
        if (ref == null)
            // it's ok, we can call this constructor
            ref = new SingletonObject();          
        return ref;
      public Object clone()
         throws CloneNotSupportedException
        throw new CloneNotSupportedException();
        // that'll teach 'em
      private static SingletonObject ref;
    }i see, they are using clone !, i dont need this. do i ? shouldi delete that method ?
    where do i put my thread's run method in this snippet ?

  • How to use I18N with a custom validator?

    This is my custom validator:
        public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
            Pattern pat=Pattern.compile(".+@.+\\.[a-z]+");
            Matcher m= pat.matcher(value.toString());
            if(!m.find())
                FacesMessage message = new FacesMessage("Not a valid e-mail address");
                throw new ValidatorException(message);
        }Instead of providing the text "Not a valid e-mai address", I'd like to get the text out of my ApplicationResources property file.
    How can I do this?
    I know how to use it with the provided validators, but not with own custom ones
    Please help me out, thanks

    I found a solution for this problem, I don't know it's best practice but here it is :
        public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
            String errortext;
            Pattern pat=Pattern.compile(".+@.+\\.[a-z]+");
            Matcher m= pat.matcher(value.toString());
            if(!m.find())
                ResourceBundle bundle =
                ResourceBundle.getBundle("be.vdab.resources.ApplicationResources", context.getViewRoot().getLocale());
                errortext = bundle.getString("erroremail");
                FacesMessage message = new FacesMessage(errortext);
                throw new ValidatorException(message);
        }

  • Can we apply custom validation before uploading data in WebADI in 12.1.3

    Hi,
    I have requirement of applying custom validation before uploading data from spreadsheet using webADI. How can we do that.
    Is there any way in desktop Integration Manager Responsibilty in WebADI.
    I have just started exploring webADI
    Please Help Me...
    Thanks,
    Suhani

    Why are you posting this in OAF?
    Anyway you can by creating a custom PL/SQL wrapper that is called by the WebADI.
    Raise an application ERROR in your wrapper and it will show in the WebADI
    If you just want to validated VALUES, you are better of creating an LOV on the Column. Then WebADI will do the validation work for you.
    Jeroen

  • Implementing Custom Validation Logic for Payment Disbursements

    Hi All,
    Is there anyone here, who has implemented Custom Validation Logic for disbursements in Oracle payments.
    Theory: Under Payments Setup Administrator -> Formats -> Formats, we can setup a payment format and even attach a XML template. Apart from this we can setup Pre-defined validations or user Defined validations.
    For Pre-defined validations / seeded validations, Oracle has provided an API
    IBY_VALIDATIONSETS_PUB.evaluateCondition. We can use this API, and call a custom package by using the keyword 'CUSTOM' in the call.
    Has anyone played around with this package and successfully implemented custom validations. Does anyone have a sample code on how to implement this. The Payment Manager Implementation guide is of little help.
    Thanks

    This document was very helpful to me in creating a custom validation.
    http://docs.oracle.com/cd/E18727_01/doc.121/e13416/T387353T419293.htm

  • Custom validator for a SelectMany component

    I did not succeed at validating a selectManyCheckBox with a custom validator.
    I want to validate that the user selected at least 1 and at most 3 checkboxes.
    The UIComponent.getSelectedValues always returns an array of length 0, even when some boxes are checked.
    Page code:
         <h:selectManyCheckbox id="selectProfessions" value="#{userBackingBean.selectedProfessionIDs}" layout="pageDirection" styleClass="category">
              <f:selectItems value="#{categoryTreeBackingBean.professionSelectItems}" />
              <f:validator validatorId="com.studio184.news.ui.validator.SelectCategoriesValidator"/>
         </h:selectManyCheckbox>
    Validate method:
    UISelectMany select = (UISelectMany)component;
    if (select.getSelectedValues() == null || select.getSelectedValues().length < 1 || select.getSelectedValues().length > 3) {
         String summary = ...
         String detail = ...
         FacesMessage message = new FacesMessage(summary, detail);
         message.setSeverity(FacesMessage.SEVERITY_ERROR);
         throw new ValidatorException(message);
    Any help would be greatly appreciated.
    Bruno
    http://www.practicalsoftwarearchitect.com

    In general, the value property is set at the end of the Process Validations phase.
    You can use getSubmittedValue() to access the submitted values.
    More simply, you can use the third argument of the validate method which is the same as the submitted value.
    For example:
    public void validate(FacesContext arg0, UIComponent arg1, Object arg2)
              throws ValidatorException {
         Object values[] = (Object [])arg2;
         if (values() == null || values().length < 1 || values().length > 3) {
         // throw exception!!
    }

  • OIM Custom validation on entitlement request submission.

    Hi,
    We have a requirement in OIM to do some custom validation on entitlement request submission through catalogue.
    Can we leverage the requestdatavalidator here. Is there any other way of doing it?
    Thanks in advance,

    What you would need to do is create a controller to allow for this functionality to occur. the processformrequest procedure is the best one to achieve this functionality. Once you have written the custom validation, personalize the page you need the control on and add in the controller.

Maybe you are looking for

  • Can't open from skydrive in Reader for Android

    I have adocument I needtowork in whileIam travelling. It had tobedownloaded fromanon-linesource and I THINK I had to use Microsoft Explorer to open it nitially. I startedtoworkon it (its a document one had to enter data into in stages). I saved it an

  • Flash Presentation not allowing connection

    The rest of the presentation works beautifully. Then the last screen I have a link to my website. When I click on it: "Macromedia Flash Player has stopped a potentially unsafe operation. The following local application on your computer or network: ..

  • Locating classes given many JAR files

    This may seem a basic thing, but I'm having trouble figuring out how people locate the correct JAR file to include when given just the package and class name. In searching for a solution to a problem I'd come across web document that tell me all abou

  • Archive to DVD

    I wish to archive some digital tapes from an old Canon camcorder. My goal is to archive the whole tape and then mount these DVD's at some future date to use various footage for FCE editing. I know that I need to capture these tapes with FCE. How do I

  • When I open itunes and try to go to store it does not open trouble shooting sayes I am not connected to internet. I am connected...

    When I open itunes the store will not open nor will it let me sign in trouble shooting says I am not connected to internet ... I am connected.