Please help me i have to finish this by tonight

Hi Herewith I have enclosed the code.. I am not sure where i am going wrong..moreover i am very new to this technologies.. i need to finish this by tonight.. anyone helps that will be great..
here is my problem.. i need to check a rebate id which exists in the database.. if it exists I have to update the value and if doesn't exits i have to insert a new row..
My jsp will contails 10 rows.. Once after submit.. I have to check with the database whetehr that rebate_sku_num exits.. if exits i need to update that row.. if not i have to insert a new record.. here is my code.. please give some solution.. thanks
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.SingleThreadModel;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import java.io.IOException;
import java.sql.ResultSet;
import java.io.*;
import java.util.*;
import java.util.Date;
import java.text.*;
public class AddRebate extends HttpServlet implements SingleThreadModel {
public void init(ServletConfig servletconfig) throws ServletException {
super.init(servletconfig);
public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException {
HttpSession session;
session = httpservletrequest.getSession(true);
String user_name;
String divisionCode;
String rebate_sku_num[];
String selectedMonth;
String amount[];
String message = "";
String Query="";
String RebateId="";
boolean flag = true;
// from here
Calendar todaysdate = new GregorianCalendar();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");     
System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
String entryDate = sdf.format(todaysdate.getTime());
String entryDate1 = sdf1.format(todaysdate.getTime());
System.out.println("entering date is " +entryDate) ; 
System.out.println("entering date is " +entryDate1) ; 
// to here
user_name = (String) session.getAttribute("user_name");
divisionCode = (String) session.getAttribute("division_code");
selectedMonth = httpservletrequest.getParameter("selectedMonth");
rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
amount = httpservletrequest.getParameterValues("amount");
System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
System.out.println("AddRebate : doPost() : amount = " + amount);
flag =true;
if (flag) {
// from here
try {
String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB";
System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID query : " + s);
ResultSet resultset = DatabaseConnection.executeQuery(s);
if (resultset != null) {
while (resultset.next()) {
RebateId = resultset.getString("REBATE_SKU_NUM");
System.out.println("the REBATE_SKU_NUM is " + RebateId);
}else{
System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID : resltset is null " );
} catch (Exception exception1) {
System.out.println("AdjustmentServlet : doGet() : exception in getting max of adjustment id");
exception1.printStackTrace();
// to herer
for (int i = 0; i < rebate_sku_num.length; i++) {
if ((rebate_sku_num[i] != RebateId)) {
System.out.println("get the values" +rebate_sku_num);
System.out.println("get the values" + RebateId);
Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
"( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
"CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
"'" + rebate_sku_num[i] + "', " +
"TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
"'" + amount[i] + "' , '" + user_name + "'" +
", TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
", '" + user_name + "'," +
" TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
System.out.println("query is executed" +Query);
}else if ((rebate_sku_num[i] == RebateId )){
Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount[i] + " where REBATE_SKU_NUM='" + rebate_sku_num[i] + "'";
System.out.println("query is executed for updation" +Query);
try {
if (DatabaseConnection.executeUpdate(Query) == 0) {
System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
DatabaseConnection.rollBack();
message = "Some problem in updating transactions. Please try again later.";
flag = false;
break;
} else {
System.out.println("AddRebate : doPost() : update sucessfull");
message = "Rebate Transactions has been updated.";
flag = true;
} catch (Exception ex) {
System.out.println("AddRebate : doPost() : exception in update query");
message = "Some problem in updating transactions. Please try again later.";
flag = false;
ex.printStackTrace();
session.setAttribute("message", message);
httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
return;

hey try this code,i made changes in ur code,ur logic wasnt good on it
thanks hithesh
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.SingleThreadModel;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import java.io.IOException;
import java.sql.ResultSet;
import java.io.*;
import java.util.*;
import java.util.Date;
import java.text.*;
public class AddRebate extends HttpServlet implements SingleThreadModel {
public void init(ServletConfig servletconfig) throws ServletException {
super.init(servletconfig);
public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException {
HttpSession session;
session = httpservletrequest.getSession(true);
String user_name;
String divisionCode;
String rebate_sku_num[];
String selectedMonth;
String amount[];
String message = "";
String Query="";
String RebateId[];
boolean flag = true;
// from here
Calendar todaysdate = new GregorianCalendar();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");
System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
String entryDate = sdf.format(todaysdate.getTime());
String entryDate1 = sdf1.format(todaysdate.getTime());
System.out.println("entering date is " +entryDate) ;
System.out.println("entering date is " +entryDate1) ;
// to here
user_name = (String) session.getAttribute("user_name");
divisionCode = (String) session.getAttribute("division_code");
selectedMonth = httpservletrequest.getParameter("selectedMonth");
rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
amount = httpservletrequest.getParameterValues("amount");
System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
System.out.println("AddRebate : doPost() : amount = " + amount);
flag =true;
if (flag) {
// from here
try {
String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB";
System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID query : " + s);
ResultSet resultset = DatabaseConnection.executeQuery(s);
if (resultset != null) {
int j=0;
while (resultset.next()) {
RebateId[j] = resultset.getString("REBATE_SKU_NUM");
System.out.println("the REBATE_SKU_NUM is " + RebateId[j]);
j++;
}else{
System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID : resltset is null " );
} catch (Exception exception1) {
System.out.println("AdjustmentServlet : doGet() : exception in getting max of adjustment id");
exception1.printStackTrace();
// to herer
for(int i=0; i<rebate_sku_num.length,i++){
     boolean flag=false;
     for (int j = 0; j < RebateId.length; j++) {
          if ((rebate_sku_num[i] == RebateId[j])) {
               flag=true;//u found this id in database,so u need to update
               break;
     if(!flag){//if not found,add into database
          System.out.println("get the values" +rebate_sku_num);
          System.out.println("get the values" + RebateId);
          Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
               "( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
               "CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
               "'" + rebate_sku_num + "', " +
               "TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
               "'" + amount + "' , '" + user_name + "'" +
               ", TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
               ", '" + user_name + "'," +
               " TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
          System.out.println("query is executed" +Query);
     else //if found just update the database
               Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount + " where REBATE_SKU_NUM='" + rebate_sku_num + "'";
               System.out.println("query is executed for updation" +Query);
     try {
          if (DatabaseConnection.executeUpdate(Query) == 0) {
               System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
               DatabaseConnection.rollBack();
               message = "Some problem in updating transactions. Please try again later.";
               flag = false;
               break;
          } else {
               System.out.println("AddRebate : doPost() : update sucessfull");
               message = "Rebate Transactions has been updated.";
               flag = true;
     } catch (Exception ex) {
          System.out.println("AddRebate : doPost() : exception in update query");
          message = "Some problem in updating transactions. Please try again later.";
          flag = false;
          ex.printStackTrace();
session.setAttribute("message", message);
httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
return;

Similar Messages

  • I have a Toshiba e-studio 2830C network printer and it will not work with mavericks. I have some software that the printer guy said to try that was for a newer model printer, but it is not working. Please help....I need this printer tonight.

    the Print Mode has a line through it and says it has not been updated.
    How do I even install new printer software,I went throught the install process but for what ever reason it is still not working.
    Aloha
    David

    Please look at Reset Printing System feature

  • Please help! i have just upgraded to an iphone 5 for work, so i have started to backup my iphone 4 but it is stuck on 'finishing sync' and has been for 20hours!what can i do?i need it for work tomorrow

    please help! i have just upgraded to an iphone 5 for work, so i have started to backup my iphone 4 but it is stuck on 'finishing sync' and has been for 20hours!what can i do?i need it for work tomorrow

    Is this what you downloaded: iTunes 10.7?
    When the update fails what if any error report do you get, specifically? Please do this before trying again:
    Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.

  • HT4623 Please  help!  i have just update my iphone 4s with 7.4 update and my phone is now asking for a password which i dont have.  I have tried my keypad lock i used before the update and also my itunes password and neither work, how do i rectify this ??

    Please  help!  i have just update my iphone 4s with 7.4 update and my phone is now asking for a password which i dont have.  I have tried my keypad lock i used before the update and also my itunes password and neither work, how do i rectify this ???

    Did you buy this iPhone new from an authorized seller?

  • Can someone please help. I have a really old MacBook that is running really slow. I want to wipe everything and reinstall the latest software but don't know how to do this. Also is there a way of keeping Microsoft Office when doing this? Thanks in advance

    Can someone please help. I have a really old MacBook that is running really slow. I want to wipe everything and reinstall the latest software but don't know how to do this. Also is there a way of keeping Microsoft Office when doing this? Thanks in advance

    You do realise that wiping the disk means that everything on the disk is erased. Everything. Photos, music, emails, ...
    So the first piece of advice is to make sure you have a back up of everything.
    You need the OS disk to reintsall the operating system. You will use that disk first to erase the drive, then to reinstall the OS.
    Here's the link for the US.  http://store.apple.com/us/product/MC573/mac-os-x-106-snow-leopard
    As for MS Office, you will need the original disk that it came on to reinstall it.

  • Why doesn't my iPhone 4 have an 'Internet tethering' options? Is it carrier related or iOs related? Please help me find the solution for this. thanx

    Why doesn't my iPhone 4 have an 'Internet tethering' options? Is it carrier related or iOs related? Please help me find the solution for this. thanx

    Personal Hot spot
    http://support.apple.com/kb/HT3574
    Understanding
    http://support.apple.com/kb/HT4517
    Trouble Shooting
    http://support.apple.com/kb/TS2756

  • I have an old version of InDesign CS5, have not used in a while..about a year.  It will not load nor allow me to uninstall and reinstall, please help.  I have original discs and serial number.  How can I fix this?

      I have an old version of InDesign CS5, have not used in a while..about a year.  It will not load nor allow me to uninstall and reinstall, please help.  I have original discs and serial number.  How can I fix this?

    CS Cleaner Tool for installation problems | CCM, CS6, CS5.5, CS5, CS4, CS3

  • Hello Please help me   I have worked erased     IPhone exists with me     But did not finish the process erased     What is the solution??

    Hello
    Please help me
    I have worked erased
    IPhone exists with me
    But did not finish the process erased
    What is the solution??

    Post in your native language, the above make not sense.

  • I have apple id but in this week i see this error : you must verify your payment info befor you can make purchases. please help me. i have not credit card but i buying apps with gift card. please help me

    i have apple id but in this week i see this error : you must verify your payment info befor you can make purchases. please help me. i have not credit card but i buying apps with gift card. please help me

    Why do you keep making multiple posts with this issue? You have now posted it three times in the last hour and have two different people helping you in two different threads!
    https://discussions.apple.com/message/18606895
    https://discussions.apple.com/message/18606685
    This is bad internet manners.

  • Please help me to have some knowledge on this

    Can any one give me 'a model of blue print along with some examples of gaps and it's solution in the project'? Please help me to have some knowledge on this.

    /* Formatted on 8/27/2012 9:54:40 AM (QP5 v5.185.11230.41888) */
    WITH t AS (SELECT 'a-->b-->c-->d' tree FROM DUAL),
         t1
         AS (    SELECT REGEXP_SUBSTR (tree,
                                       '[^-->]+',
                                       1,
                                       LEVEL)
                           parent,
                        REGEXP_SUBSTR (tree,
                                       '[^-->]+',
                                       1,
                                       LEVEL + 1)
                           child,
                        LEVEL lvl
                   FROM t
             CONNECT BY LEVEL <= REGEXP_COUNT (tree, '-->') + 1)
        SELECT DISTINCT PRIOR parent || '-->' || parent PATH
          FROM t1
         WHERE PRIOR parent IS NOT NULL
    CONNECT BY PRIOR lvl < lvl
    c-->d
    a-->d
    a-->b
    b-->d
    b-->c
    a-->c

  • How do I transfer my checked songs from one computer to another - tried exporting library playlist etc but no luck! Please help! I have 26,000 songs - 17,000 are selected and I can't run down the list on my new computer and re-check 17,000 songs! Thanks!

    How do I transfer my checked songs from one computer to another - tried exporting library playlist etc but no luck! Please help! I have 26,000 songs - 17,000 are selected and I can't run down the list on my new computer and re-check 17,000 songs! Thanks!

    Make a smart playlist of your whole library but only checked songs - #4 on  http://support.apple.com/kb/ht1801
    Highlight all files in that playlist, then drag to the other drive.  This isn't preserving any playlists or whatever, just copying files from one drive to another.
    You might want to delete the smart playlist this once you are done because it will probably gobble up resources with that many files.

  • Please help me to come out of this dilemma.

    Hi
    I am in dilemma.
    Recently i have joined a new organization which is a world leader in its field . The company name is very popular around the globe. But the thing is its almost 4 months , and as an Oracle DBA , i am not getting chance to work on something interesting / challenging . The thing is , i studied the environment here and i think most of my work involves only preparing DB docs , attending meeting and raising support tickets once a while. So very minimal technical work.
    To be honest, in last 4 years of my career i haven't worked in such a large organization before so during interview i didn't ask for type of work ,and i just wanted to join this organization as it will have a dramatic impact when i mention the name in my resume . I do not want to quit this organization so early because it will have a bad impression . Also , i think speaking to my bosses will not work because they cant help it in any way .
    I am happy with every thing else here , but i want to leave this company for doing something challenging as an Oracle DBA , but want to stay here because every thing else is damn good and also when i switch to a new company after 2 years , people will be dying to hire me ;) , am i contradicting ?
    Please help me to come out of this dilemma.
    Thanks

    Well, joining a big company from a small company and then leaving it just in few days would actually backfire. Next hiring people would think that since you were in capable to handle the workload in a big company(because you never worked in such environment before), you were thrown out. You won't be able to justify your reason that you left because you didnt' find enough challenge there because it can be completely blown away by a simple counter that how did you know that there was no challenging work there as you never stayed there even for a year too! So IMO, you would do more harm for you than anything good be quitting now. Its a mistake not to ask about the work but you have committed it already . What you should n't do is to do add another one and that is to leave the company now.
    Since you are not having much work, why don't you use it learn more about the company, its various works, other divisons and above all, to learn oracle database in your spare time. There is no place where you would be given challenges for your sake. If there is work it would come to you else you would be remaining free. You are working as a normal dba I believe not in support or something like that for you, every time, a new issue ticket is ready. If you have spare time with you, use it wisely to understand how things are working , both in your organization and with oralce db. Spend time doing trainings and learn more about the product, complete at least and then leave.
    Just my 2 cents.
    Aman....

  • Emergency! Please Help. I have an iPhone 4 with all my pictures from the vacation on it and I plugged into my computer and it sync'ed to my ipod.  all of my pictures are gone.  How do I get my pictures back?

    Emergency! Please Help. I have an iPhone 4 with all my pictures from the vacation on it and I plugged into my computer and it sync'ed to my ipod.  all of my pictures are gone.  How do I get my pictures back?

    If all you did was sync your phone, and if you haven't synced again since this happened, you can restore your phone from the backup that was created at the beginning of the sync process (camera roll photos are included in the backup).  If you have synced again since this happened this backup has already been overwritten and your photos are lost.  Also, if you restored your phone from the backup of your iPod, rather than just synced, then your  photos are lost too.
    If you have an intact backup that contains these photos, do the following:
    Without connecting your phone, open iTunes on your computer and go to Preferences.  On the Devices tab check "Prevent...from syncing automatically".
    Connect your phone to your computer, right-click on the name of your phone when it appears in iTunes on the left sidebar and select Restore from Backup, choose your most recent backup to restore from.
    When complete, you can go back to iTunes>Preferences>Devices and re-enable automatic syncing.

  • The enter key is not working in firefox but it has working fine in chrome and IE so please help me to rid out from this.

    The enter key is not working in firefox but it has working fine in chrome and IE so please help me to rid out from this.

    Hello gokulaan, '''try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • I upgraded to mountain lion a week ago and now on startup of my macbook pro, microsoft excel and word start up automatically and then crash? very strange can anyone please help? I have checked the login items under users and groups and there is nothing.

    I upgraded to mountain lion a week ago and now on startup of my macbook pro, microsoft excel and word start up automatically and then crash? very strange can anyone please help? I have checked the login items under users and groups and there is nothing.

    Are you using the Office for Mac 2011 version, as you need to do?  The Office for Mac 2004 is Not at all compatible with Mountain Lion, and the 2008 version has been noted to have some problems running with ML.
    Hope this helps

Maybe you are looking for