NumberFormat Exception

I have no idea why I am getting this error. It is kind of freaky because sometimes it appears and other times it doesn't. This is the piece of code it is coming from:
for (int w = 0; w <= pm-pf; w++) {
   jTable4.setValueAt("Survey", new Integer(SelectionList.get(w).toString()).intValue(), 6);
   jTable4.setValueAt("Survey", new Integer(SelectionList.get(w).toString()).intValue(), 8);
   Double surveyvalue = new Double(jTable4.getValueAt(new Integer(SelectionList.get(w).toString()).intValue(),3).toString());
   jTable4.setValueAt(surveyvalue,new Integer(SelectionList.get(w).toString()).intValue(),5);
   jTable4.setValueAt(jTable4.getValueAt(new Integer(SelectionList.get(w).toString()).intValue(),4),new Integer(SelectionList.get(w).toString()).intValue(),7);
}The error is on this line:
   jTable4.setValueAt(surveyvalue,new Integer(SelectionList.get(w).toString()).intValue(),5);When I test out this line:
jTable4.setValueAt(new Double(-0.1801),4,5);It works just fine. The value of surveyvalue is:
-0.1805
so I don't understand why I am getting this error:
Exception occurred during event dispatching:
java.lang.IllegalArgumentException: Cannot format given Object as a Number
     at java.text.NumberFormat.format(NumberFormat.java:209)
     at java.text.Format.format(Format.java:121)
     at javax.swing.JTable$DoubleRenderer.setValue(JTable.java:3210)
     at javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent(DefaultTableCellRenderer.java:161)
     at javax.swing.JTable.prepareRenderer(JTable.java:3540)
     at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:995)
     at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:917)
     at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:858)
     at javax.swing.plaf.ComponentUI.update(ComponentUI.java:39)
     at javax.swing.JComponent.paintComponent(JComponent.java:395)
     at javax.swing.JComponent.paint(JComponent.java:687)
     at javax.swing.JComponent.paintChildren(JComponent.java:498)
     at javax.swing.JComponent.paint(JComponent.java:696)
     at javax.swing.JViewport.paint(JViewport.java:668)
     at javax.swing.JComponent.paintChildren(JComponent.java:498)
     at javax.swing.JComponent.paint(JComponent.java:696)
     at javax.swing.JComponent.paintChildren(JComponent.java:498)
     at javax.swing.JComponent.paint(JComponent.java:696)
     at javax.swing.JComponent.paintChildren(JComponent.java:498)
     at javax.swing.JComponent.paint(JComponent.java:696)
     at javax.swing.JComponent.paintChildren(JComponent.java:498)
     at javax.swing.JComponent.paint(JComponent.java:696)
     at javax.swing.JLayeredPane.paint(JLayeredPane.java:546)
     at javax.swing.JComponent.paintChildren(JComponent.java:498)
     at javax.swing.JComponent.paint(JComponent.java:669)
     at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:23)
     at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:54)
     at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:91)
     at java.awt.Container.paint(Container.java:960)
     at javax.swing.JFrame.update(JFrame.java:329)
     at sun.awt.RepaintArea.update(RepaintArea.java:337)
     at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:200)
     at java.awt.Component.dispatchEventImpl(Component.java:2663)
     at java.awt.Container.dispatchEventImpl(Container.java:1213)
     at java.awt.Window.dispatchEventImpl(Window.java:914)
     at java.awt.Component.dispatchEvent(Component.java:2497)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
Now, if I put a System.out.println(); in before the setValueAt, it works. I am banging my head against the wall.
Any ideas?
Thanks.
Allyson

Here is my table model:
  class MyFTableModel extends DefaultTableModel {
    public Class getColumnClass(int c) {
      return getValueAt(0, c).getClass();
    public MyFTableModel(Vector columnNames, int numRows)
      super(columnNames, numRows);
    public boolean isCellEditable(int row, int column) {
      return false;
  }Is this the reason why?
Thanks.
Allyson

Similar Messages

  • Help with New NumberFormat Exception

    Hello. I'm new to java and I can't figure this out. I'm trying to prevent customers from entering a negative value for the quantity or price with a (quantity <= 0)New NumberFormat Exception but it's not working. The negative values are being calculated in the grand total giving impossible results. -$4.50 can't be. How can I fix this problem?
    Is this the right forum for my question? If its not, please move this away.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Date;
    import java.text.*;
    import java.text.DecimalFormat;
    public class BookOrderApplet extends Applet implements ActionListener
         //Declare variables.
         String Title, Author, answer;
         int quantity, numBooks, numTrans;
         double price, lastTot, subTotal, shipping, salesTax, total;
         //Create Date.
         Date currentDate = new Date();
         //Create Labels.
         Label dateLabel = new Label("" + currentDate);
         Label lblBookTitle = new Label("Book Title: ");
         Label lblAuthor = new Label("Author:");
         Label lblPrice = new Label("Price");
         Label lblQuantity = new Label("Quantity:");
         Label lblNumberOfLastTransactions = new Label("Number of Tansactions: 0");
         Label lblLastItemTotal = new Label("Last Item Total: 0");
         Label lblNumberOfBooks = new Label("Number of Books: 0");
         Label lblSubTotal = new Label("Subtotal: 0");
         Label lblSalesTax = new Label("Sales Tax: 0");
         Label lblShipping = new Label("Shipping: 0");
         Label lblOrderTotal = new Label("Order Total: 0");
         //Create TextFields.
         TextField txtTitle = new TextField(13);
         TextField txtAuthor = new TextField(13);
         TextField txtPrice = new TextField(20);
         TextField txtQuantity = new TextField(20);
         TextArea statusArea = new TextArea();
         //Create Buttons.
         Button calcButton = new Button("Calculate Total");
         Button resetButton = new Button("Reset Form");
         //Constructing the interface.
         public void init()
              //Add Labels.
              add(dateLabel);
              add(lblBookTitle);
              add(lblAuthor);
              add(lblQuantity);
              add(lblPrice);
              add(lblNumberOfLastTransactions);
              add(lblLastItemTotal);
              add(lblNumberOfBooks);
              add(lblSubTotal);
              add(lblSalesTax);
              add(lblShipping);
              add(lblOrderTotal);
              //Add Fields.
              add(txtTitle);
              add(txtAuthor);
              add(txtQuantity);
              add(txtPrice);
              //Add buttons.
              add(calcButton);
              add(resetButton);
              add(statusArea);
              setBackground(Color.white);
              statusArea.getPreferredSize();
              calcButton.addActionListener(this);
              resetButton.addActionListener(this);
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == calcButton)
                   Title = txtTitle.getText();
                   Author = txtAuthor.getText();
                   quantity = getQuant();
                   price = getPrice();
                   transCount();
                   lastTot();
                   numBooks();
                   subTotal();
                   salesTax = salesTax();
                   shipping = shipping();
                   total = total();
                   answer = outFormat();
              else
              //resetButton should clear all the fields.
                        txtTitle.setText("");
                        txtAuthor.setText("");
                        txtQuantity.setText("");
                        txtPrice.setText("");
                        lblNumberOfLastTransactions.setText("Number of Tansactions: 0");
                        lblLastItemTotal.setText("Last Item Total: 0");
                        lblNumberOfBooks.setText("Number of Books: 0");
                        lblSubTotal.setText("Subtotal: 0");
                        lblSalesTax.setText("Sales Tax: 0");
                        lblShipping.setText("Shipping: 0");
                        lblOrderTotal.setText("Order Total: 0");
                        statusArea.setText("");
         //Prevent user from entering invalid quanity numbers.
         public int getQuant()
              try
                   quantity = Integer.parseInt(txtQuantity.getText());
                   if (quantity <= 0) throw new NumberFormatException();
              catch (NumberFormatException g)
                   statusArea.setText("Please enter a valid number for quantity.");
              return quantity;
         //Prevent user from entering invalid price numbers.
         public double getPrice()
              try
                    price = Double.parseDouble(txtPrice.getText());
                    if(price <= 0) throw new NumberFormatException();
              catch (NumberFormatException h)
                   statusArea.setText("Please enter a valid number for price.");
              return price;
         //Add up the number of transactions.
         public void transCount()
              numTrans = numTrans + 1;
              lblNumberOfLastTransactions.setText ("Number of Transactions: " + numTrans);
         //Previous Item Total.
         public void lastTot()
              DecimalFormat twoDigits = new DecimalFormat("#0.00");
              lblLastItemTotal.setText ("Last Item Total: $" + twoDigits.format(subTotal));
         //Add up the number of books.
         public void numBooks()
              numBooks = Integer.parseInt(txtQuantity.getText()) + numBooks;
              lblNumberOfBooks.setText ("Number of Books: " + numBooks);
         //Multiply price * quanity to get SubTotal.
         public void subTotal()
              DecimalFormat twoDigits = new DecimalFormat("#0.00");
              subTotal = price * quantity;
              lblSubTotal.setText("Subtotal: $" + twoDigits.format(subTotal));
         //Need to put a Sales Tax value later.
         public double salesTax()
              lblSalesTax.setText("Sales Tax: " + salesTax);
              return 0;
         //Shipping Total
         public double shipping()
              if (subTotal >= 50)
                   lblShipping.setText("Shipping: FREE!");
                   return 0;
              else
                   shipping = numBooks * 2;
                   lblShipping.setText("Shipping: " + shipping);
              return shipping;
         //GrandTotal
         public double total()
              DecimalFormat twoDigits = new DecimalFormat("#0.00");
              total = subTotal + shipping + salesTax;
              lblOrderTotal.setText("Order Total: $" + twoDigits.format(total));
              return total;
         //Put everything together.
         public String outFormat()
              DecimalFormat twoDigits = new DecimalFormat("#0.00");
              String answer = "You ordered: " + Title + " by " +  Author + "." + "     You purchased: " + quantity + " copies for $" + twoDigits.format(price) + " per item." + "    The Grand Total comes to: $" + twoDigits.format(total) ;
              statusArea.append("\n");
              statusArea.append(answer);
              return answer;
    }

    I suggest changing your code slightly. In the actionPerformed() method when you are calling other methods to parse the input, use a try/catch block around those methods. Something like thispublic void actionPerformed(ActionEvent e) {
              if(e.getSource() == calcButton) {
                   try {
                        Title = txtTitle.getText();
                        Author = txtAuthor.getText();
                        quantity = getQuant();
                        price = getPrice();
                        transCount();
                        lastTot();
                        numBooks();
                        subTotal();
                        salesTax = salesTax();
                        shipping = shipping();
                        total = total();
                        answer = outFormat();
                   } catch(NumberFormatException ne) {
              } else {
                   //resetButton should clear all the fields.
         }Then, inside the methods that parse the data, change the code so the exception is thrown to the caller, something like this     //Prevent user from entering invalid quanity numbers.
         public int getQuant() {
              boolean error = false;
              try {
                   quantity = Integer.parseInt(txtQuantity.getText());
              } catch(NumberFormatException ne) {
                   error = true;
              error = error | quantity <= 0;
              if (error) {
                   statusArea.setText("Please enter a valid number for quantity.");
                   throw new NumberFormatException();
              return quantity;
         }This allows the error to cause the program to skip calculating.
    I also think you have a logic problem with how you are calculating shipping.

  • Handling Consecutive NumberFormat Exceptions

    I have written a Binary Search Program for which I am asking the user to enter the size and the elements of the array.
    If the user enters the size say 5
    Now he can enter up to a max of 5 max numbers to populate the array.
    If the user enters an alphabet it should not be accepted and it would throw an exception and its caught properly for the first time and the user is asked to enter the number again. Now again if the user enters an alphabet my program is not robust enuf to throw an error to the user and continue the user to enter a number from that point. How do i handle such exceptional conditions.
    import java.util.Arrays;
    import javax.swing.JOptionPane;
    public class BinarySearch {
         public static void main(String[] args) {
              String n = JOptionPane.showInputDialog(null, "Enter the size of the array");
              int size = Integer.parseInt(n);
              int a[] = new int[size];
              int i = 0;
              while(i < size){
                   String arrayn = JOptionPane.showInputDialog(null, "Enter the "+(i+1)+" th element of the array");
                   try{
                        a[i] = Integer.parseInt(arrayn);
                   }catch (Exception e){
                        arrayn = JOptionPane.showInputDialog(null, "Enter the "+(i+1)+" th element of the array");
                        a[i] = Integer.parseInt(arrayn);
                   i++;
              System.out.print("The elements of the array are : ");
              for(int j = 0; j < size; j++){
                   System.out.print(a[j]+"  ");     
              Arrays.sort(a);               //Sorting the numbers for Binary Search
              System.out.println();
              System.out.print("The Sorted elements of the array are : ");
              for(int j = 0; j < a.length; j++){
                   System.out.print(a[j]+"  ");     
              String key = JOptionPane.showInputDialog(null, "Enter the element to search for from the array");
              int searchKey = Integer.parseInt(key);
              int position = binarySearch(a, searchKey);
              System.out.println();
              if(position == -1){
                   System.out.println("The element could not be found");
              }else{
                   System.out.println("The element found at "+position+"th position of the array");
         public static int binarySearch(int a[], int searchKey){
              int low, high, middle;
              int index = -1;
              low = 0;
              high = a.length - 1;
              middle = (low + high + 1) / 2;
              do{
                   if(searchKey == a[middle]){
                        return middle;
                   }else if(searchKey < a[middle]){
                        high = middle -1;
                   }else{
                        low = middle + 1;
                   middle = (low + high + 1) / 2;
              }while(low <=high && (index == -1));
              return index;
    }Message was edited by:
    hemanthjava

    Hi,
    I made the changes. I am getting NumberFormat Error for the size even after making a change.
    int k = 0;
              while(k < 1){
                   try{
                        n = JOptionPane.showInputDialog(null, "Enter the size of the array");
                        k++;
                   }catch (Exception e) {
                        System.out.println("Please enter a number for size");
                        continue;
    Exception in thread "main" java.lang.NumberFormatException: For input string: "j"
         at java.lang.NumberFormatException.forInputString(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at BinarySearch.main(BinarySearch.java:19)
    Message was edited by:
    hemanthjava

  • Java.lang.numberformat exception

    Hi,
    I have a situation wherein i am trying to assign a integer parameter value (coming from a SQL Server Stored Procedure) into an int variable in the program and i am getting the above exception.
    The data format is same in the sense, incoming parameter can have a possible value of 0 or 1 or 2. The local variable in the program is initliazed to 3.
    Please let me know if you have a solution.
    Regards
    Ramesh

    What is the line of code causing the Exception? What is the datatype that the stp returns and what is the datatype of the column in the db?

  • NumberFormat Exception while attaching files to Service Request

    We are getting this error from one responsibility and not from the other one.
    I have checked that the Type-responsibility mapping is similar for both the responsibilities.
    java.lang.NumberFormatException: For input string: "EEC000"
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         at java.lang.Long.parseLong(Long.java:394)
         at java.lang.Long.<init>(Long.java:630)
         at oracle.apps.fnd.framework.webui.OAPageContextImpl.parseMultipartForm(OAPageContextImpl.java)
         at oracle.apps.fnd.framework.webui.OAPageContextImpl.<init>(OAPageContextImpl.java:544)
         at oracle.apps.fnd.framework.webui.OAPageBean.createPageContext(OAPageBean.java:4320)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1206)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
         at oa_html._OA._jspService(_OA.java:88)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
         at oracle.jsp.JspServlet.service(JspServlet.java:156)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
         at org.apache.jserv.JServConnection.run(JServConnection.java:294)
         at java.lang.Thread.run(Thread.java:534)

    This URL is the Agent Dashboard you are talking about, this page cannot be used to Create SR, in this the agent can only view SRs in his queue.
    No patch would be there from Oracle which makes SR flow in OAF, this is a CRM module and is built on JTF fwk using AK dictionary.
    For CS, few setups screens have been converted into OA pages in 11.5.10, these were forms in 11.5.9, for example the req type-resp mapping screen.
    Thanks,
    Tapash

  • Numberformat exception, xdk bug ????

    Hi,
    as i insert an xml with some decimal number eg. 5.2 . then the following error occur:
    oracle.xml.sql.OracleXMLSQLException: 'java.lang.NumberFormatException: 5.2' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
    i want to ask whether this is a bug of the xdk !!!
    i am using :
    jdbc - classes111.zip
    xdk version - xdk_java_9_0_2_0_0B
    can anybody HELP me ???
    i tried to fix it using 3 days already !!!
    Thanks
    Regards
    Ivan
    null

    Same problem wth the 90110a XDK release for plsql on unix and win. An earlier version of this worked (we were on whatever version shipped with Oracle 8.1.7 near the beginning of this year). Bug workaround is to create views of your base tables making all of your numeric columns into character columns (to_char(col_name) ) and then to write instead-of triggers on the views to insert the data to the target table. When will this be fixed or is this the way it will work from now on?

  • Exception in thread "main" java.lang.NumberFormat Exception

    Could some one tell me what this mean? Thank you.

    import javax.swing.*;
    import java.text.DecimalFormat;
    import java.text.*;
    public class CollegeBill{
       public static void main (String Args[])
          int hours, classNumber, collegeNumber, tuition, fees, total=0, records=0, rate;
          String hoursInput, classInput, collegeInput, classification, collegeName;
    //setup for decimal format 0.00
          DecimalFormat twoDigits = new DecimalFormat ("0.00");
    //Create output display
          JTextArea outputTextArea = new JTextArea (15,35);
          JScrollPane scroller = new JScrollPane (outputTextArea);
    //set headings in text output
          outputTextArea.setText("Credits\tLevel\tCollege\tTotal\nHours\t\t\tBill\n");
          outputTextArea.append("_______\t_____\t_______\t_____\n");
    //recieve input
          hoursInput=JOptionPane.showInputDialog("Enter number of credit hours, -1 to exit: ");
          hours = Integer.parseInt(hoursInput);
    //check hours
          while ((hours==0)||(hours<-1)||(hours>21))
         JOptionPane.showMessageDialog(null,"You entered "+hours+" credit hours,\n credit hours must be between 1 and 21. ", "Error ", JOptionPane.ERROR_MESSAGE);
            hoursInput=JOptionPane.showInputDialog("Enter number of credit hours, -1 to exit: ");
            hours = Integer.parseInt(hoursInput);
    //create records util -1 entered
          while(hours!=-1)
         classInput=JOptionPane.showInputDialog("Enter classification 1 for U, 2 for G: ");
         classNumber=Integer.parseInt(classInput);
         while((classNumber<1)||(classNumber>=3))
            JOptionPane.showMessageDialog(null, "You entered classification "+classNumber+"\n Classification must be either 1 or 2. ", "Error ", JOptionPane.ERROR_MESSAGE);
               classInput=JOptionPane.showInputDialog("Enter classification 1 for U, 2 for G: ");
               classNumber=Integer.parseInt(classInput);
         collegeInput=JOptionPane.showInputDialog("Enter college ID number:\n 1 for Business\n 2 for Engineering\n 3 for Liberal Arts\n 4 for Science");
         collegeNumber=Integer.parseInt(collegeInput);
         while((collegeNumber<1)||(collegeNumber>=5))
            JOptionPane.showMessageDialog(null, "you entered college code "+collegeNumber+"\nCollege code must be either 1, 2, 3 or 4. ", "Error ", JOptionPane.ERROR_MESSAGE);
            collegeInput=JOptionPane.showInputDialog("Enter college ID number:\n 1 for Business\n 2 for Engineering\n 3 for Liberal Arts\n 4 for Science");
            collegeNumber=Integer.parseInt(collegeInput);
         if (classNumber==1)
         classification="U";
           rate = 125;
         else
         classification="G";
         rate = 225;
         switch (collegeNumber)
              case 1:
                collegeName="Business";
                break;
              case 2:
                collegeName="Engineering";
                break;
              case 3:
                collegeName="Liberal Arts";
                break;
              case 4:
                collegeName="Science";
                break;
              default:
                collegeName="Error";
                break;
         if(((classNumber==1)&&(hours>=12))||((classNumber==2)&&(hours>=9)))
         tuition=hours*rate;
         if (collegeNumber==1)
           fees=hours*6;
           tuition+=fees;
         if (collegeNumber==2)
           fees=hours*5;
           tuition+=fees;
         outputTextArea.append(hours+"\t"+classification+"\t"+collegeName+"\t"+twoDigits.format
    (tuition)+"\n");
         total+=tuition;
         records++;
         else
         outputTextArea.append(hours+"\t"+classification+"\t"+collegeName+"\t Insufficient hours\n");
         hoursInput=JOptionPane.showInputDialog("Enter number of credit hours, -1 to exit: ");
         hours=Integer.parseInt(hoursInput);
         while ((hours==0)||(hours<-1)||(hours>21))
         JOptionPane.showMessageDialog(null, "You entered "+hours+ "credit hours,\n credit hours muste be between 1 and 21.","Error", JOptionPane.ERROR_MESSAGE);
         hoursInput=JOptionPane.showInputDialog("Enter number of credit hours, -1 to exit: ");
         hours=Integer.parseInt(hoursInput);
    if (records>0)
          outputTextArea.append("Average bill per student: "+twoDigits.format
    (((double)total/records))+"\n");
       outputTextArea.append("______________________________________________________________\n");
       outputTextArea.append("Total number of records: "+records+"\n");
       outputTextArea.append("Total amout of tuition: "+twoDigits.format(total)+"\n");
       else
          outputTextArea.append("No record, average bell per sutdent is $0.00");
       JOptionPane.showMessageDialog(null, scroller, "College Bill",
    JOptionPane.INFORMATION_MESSAGE);
       System.exit(0);
       }

  • Throwing NumberFormat exception

    iam using this code but it is throwing NumberFormatException can anybody help thanks in advance.
    int p_in_size=Integer.parseInt(request.getParameter("p_init_size"));

    "p_init_size" is either the wrong name or it contains non-numeric data.
    Try printing out request.getParameter("p_init_size") before the parseInt to see what data it is actually getting.

  • Exception already caught

    when i try to compile this code it tells me NumberFormat Exception has already been caught, but this is the only try/catch statement in the program... why is this?
                             try
                                  //make the new automata
                                  automaton = new CellularAutomaton(neighbors,depth,base,Integer.valueOf(rule.getText()).intValue(),states);
                                  timer.start();
                                  goButton.setText("Stop");
                                  status.setText(" ");
                             catch(IllegalArgumentException e1)
                                  status.setText("Invalid decimal number");
                             catch(NumberFormatException e2)
                                  status.setText("Invalid decimal number");
                             }

    If you want. It just depends on what you want your program to do. You may want one behavior if there's a NumberFormatException and something else for an IllegalArgumentException. If not, IllegalArgumentException will catch NumberFormatException...
    Hope this helps!

  • Date Format in servlet when i insert into database

    I am inserting data into database through servlet, but i am getting NumberFormat Exception, and my datatype in database is DATE ,when i typecast my day and year because they r in int and changing into String,still i am getting the same error .So please can any one tell me where to cahnge the format of date and how to type cast to my Date format of database.
    Thanks,
    lalitha

    My code is:import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.text.*;
    import java.sql.Date;
    import java.util.*;
    public class RegisterServlet extends HttpServlet
         Connection con;
         PreparedStatement ps;
    public void init(ServletConfig sc) throws ServletException
         try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         con=DriverManager.getConnection("jdbc:odbc:plk","scott","tiger");
         System.out.println("connection created");
         catch(Exception e)
         System.out.println(e);
    public void doPost(HttpServletRequest req, HttpServletResponse res)
         try
         res.setContentType("text/html");
         PrintWriter pw= res.getWriter();
    String ulogin=req.getParameter("login").trim();
    String uph1=req.getParameter("ph1").trim();
    int ph1=Integer.parseInt(uph1);
    String upass=req.getParameter("pass").trim();
    String uph2=req.getParameter("ph2").trim();
    int ph2=Integer.parseInt(uph2);
    String cpass=req.getParameter("cfm").trim();
    String uweb=req.getParameter("web").trim();
    String ufirst=req.getParameter("first").trim();
    String uaddress=req.getParameter("address").trim();
    String umiddle=req.getParameter("middle").trim();
    String ucity=req.getParameter("city").trim();
    String ulast=req.getParameter("last").trim();
    String uzip=req.getParameter("zip").trim();
    int zip=Integer.parseInt(uzip);
    String ud=req.getParameter("Aday").trim();
    String um=req.getParameter("Amonth").trim();
    String uy=req.getParameter("Ayear").trim();
    SimpleDateFormat din=new SimpleDateFormat("dd-mm-yyyy");
    SimpleDateFormat dout=new SimpleDateFormat("yyyy/mm/dd");
    String txtDate="2001-07-07";
    Date date=din.parse(txtDate);
    java.sql.Date dt=new java.sql.Date(txtDate);
    dout.format(dt);
    String usex=req.getParameter("sex").trim();
    String uemail=req.getParameter("email").trim();
    String ust=req.getParameter("st").trim();
    String ucty=req.getParameter("cty").trim();
    ps=con.prepareStatement("insert into Userdetails values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
    ps.setString(1,ulogin);
    ps.setString(2,uph1);
    ps.setString(3,upass);
    ps.setString(4,uph2);
    ps.setString(5,cpass);
    ps.setString(6,uweb);
    ps.setString(7,ufirst);
    ps.setString(8,uaddress);
    ps.setString(9,umiddle);
    ps.setString(10,ucity);
    ps.setString(11,ulast);
    ps.setString(12,uzip);
    ps.setDate(13,dt);
    ps.setString(14,usex);
    ps.setString(15,uemail);
    ps.setString(16,ust);
    ps.setString(17,ucty);
    int i=ps.executeUpdate();
    if(i==1)
    pw.println("<h3><center> Thankyou! Your details have been stored. </center></h3>");
    res.sendRedirect("http://localhost:8080/SeekLogin.html");
    pw.close();
    else
         pw.println("<h3><center>Sorry! you are not registered properly. </center></h3>");
    pw.close();
    catch(Exception e)
         System.out.println(e);
    Can anyone look this code and help me out where i am doing the mistake.
    Thanks.

  • How to Increase size of order no field in the existing acc registration?

    Hello All,
    My question is How can I increase the size of the Order number field in 'Need online access to your existing account regisrtation' form?
    In the B2B registration process of a user of an existing account.
    When a user clicks on 'Need online access to your existing corporate account?'
    The following form appears with 3 fields Account number, Order Number and Order Date along with username, password and email fields.
    The order number field is only 10 characters. We need the ability to enter order number with 11-12 characters . Can you please describe the changes that need to happen?
    Do we need to modify the ibeCRgdBusinessCreatePartial directly?
    I have modified this jsp but I get a java.lang.numberformat exception whenver I try to input more than 10 characters.
    I will be very grateful if you can help.
    Many Thanks
    SR
    Edited by: user624059 on 23-Jun-2011 06:18

    Thank you for replying to my question...
    Raised an SR,l it needs a change in ibeCRgdBusinessCreatePartial.jsp & ibeCRgpBusinessCreatePartial.jsp.

  • Error in retrieving value from the inputfield.

    Hi Experts,
    There is this behaviour I saw in WD which was understood by me.
    Let me explain it :
    I am doing a comparison scenario where I compare 2 products in a grid format.
    For this I have a table with a various types of variants.
    In this grid I have a inputfield which takes an integer input and based on which there is an effect on other variant field of that product.
    Now I am retriving the value of the input field in the modify view through
    input.getValue(); parse this string to an Integer and then pass it to the model.
    Here is the problem everything works fine when the user goes and changes the value for the firsttime but if he does the same thing without the input field loosing focus it throws a Numberformat exception this occurs because the string value retrived this time is an empty string which obviously can't be parsed.
    Can anyone explain me the why is it behaving in this way?
    Any help will be truly appriciated.
    Best Regards & Thanks in Advance
    Amit

    Hi,
    If u want to change the focus before retrieving the data from input field, try
    IWDButton b=(IWDButton)view.getElement("Button");
    b.requestFocus();
    before
    IWDInputField in1=(IWDInputField)view.getElement("InputField2");
    int a=Integer.parseInt(in1.getValue());
    Regards
    Fahad Hamsa

  • Problem retreving datetime

    hi
    how to retrieve datetime with result;
    if i use rs.getDate("CREATE_DATE") i am getting numberformat exception?i am using oracle database?
    i want in this format 12-Jul-2003 14:20 format???
    can anybody give me code
    SELECT TO_CHAR(CREATE_DATE, 'DD-MON-YYYY HH24:MI') AS CREATE_DATE FROM COMPLAINT_DETAILS A,COMPLAINT_MASTER B, OFFICE_HIRARCHY C,CONSUMER_MASTER D,USER_MASTER E WHERE RECORD_STATUS='ACTIVE'

    Remove the TO_CHAR() in your sql string. Else it just return a String but not a Date then cause the NumberFormat exception.

  • JCA Connection failed (JDE Adapter)

    Hi
    I'm trying to connect witn JDE 12 by JDE Adapter.
    I copied Connector.jar, Kernel.jar, log4j.jar and orcl_OneWorld_Adapter_896.jar into $Oracle_HOME\adapters\application\lib\
    I configured JCA Connection
    I get this below error..
    09.07.2007 19:14:44.0556 MSD - Thread[AWT-EventQueue-0,6,main] [error] [IWAF JCA] [container] [AE manager] Unable to initialized disposition 'com.ibi.mail.MailEmitterAdapter'. Problem loading class 'com.ibi.mail.MailEmitterAdapter'.
    09.07.2007 19:15:15.0665 MSD - Thread[Thread-14,6,main] [info ] [IWAF JCA] [container] [JDEdwards.service_JDEConnection] Created adapter instance for class'class com.ibi.jde.AdapterBean'.
    09.07.2007 19:15:15.0680 MSD - Thread[Thread-14,6,main] [error] [IWAF JCA] [container] [JDEdwards.service_JDEConnection] Test connectivity request failed:
    09.07.2007 19:15:15.0680 MSD - Thread[Thread-14,6,main] [error] [IWAF JCA] [container] [JDEdwards.service_JDEConnection] <jdeRequest type="callmethod" user="PSFT" role="*ALL" pwd="" environment="DV811" session="" sessionidle="">
    <callMethod name="ReturnTodaysDate" app="" runOnError="" trans="">
    <params>
    param name="jdedateDateForToday"/>
    </params>
    <onError abort=""/>
    </callMethod>
    </jdeRequest>
    09.07.2007 19:15:15.0680 MSD - Thread[Thread-14,6,main] [error] [IWAF JCA] [container] [JDEdwards.service_JDEConnection] Problem activating adapter. (Failed to connect to J. D. Edwards, check system availability and/or configuration parameters: java.lang.NumberFormatException: For input string: "4 2 8 2 5 "
    java.lang.IllegalArgumentException: Failed to connect to J. D. Edwards, check system availability and/or configuration parameters: java.lang.NumberFormatException: For input string: "4 2 8 2 5 "
    at com.ibi.jde.AdapterBean.testConnectivity(AdapterBean.java:524)
    at com.ibi.jde.AdapterBean.activate(AdapterBean.java:498)
    at com.iwaysoftware.af.container.adapter.ProxyAdapter.activate(ProxyAdapter.java:104)
    at com.iwaysoftware.af.container.adapter.AdapterConfiguration.activateAdapter(AdapterConfiguration.java:319)
    at com.iwaysoftware.af.container.adapter.AdapterConfiguration.getActivatedAdapter(AdapterConfiguration.java:299)
    at com.iwaysoftware.af.container.AdapterManager.getActivatedAdapter(AdapterManager.java:269)
    at com.iwaysoftware.af.container.IWAFContainer.getActivatedAdapter(IWAFContainer.java:515)
    at com.iwaysoftware.af.container.AEManager.getTargetAdapter(AEManager.java:643)
    at com.iwaysoftware.af.container.ae.AETargetMessage.buildGETTARGET(AETargetMessage.java:255)
    at com.iwaysoftware.af.container.ae.AETargetMessage.build(AETargetMessage.java:84)
    at com.iwaysoftware.af.container.ae.AETargetMessage.<init>(AETargetMessage.java:54)
    at com.iwaysoftware.af.container.AEManager.dispatch(AEManager.java:128)
    at com.iwaysoftware.af.container.IWAFContainer.dispatchAERequest(IWAFContainer.java:601)
    at com.ibi.afjca.cci.IWAFInteraction.execIWAE(IWAFInteraction.java:273)
    at com.ibi.afjca.cci.IWAFInteraction.exec(IWAFInteraction.java:155)
    at com.ibi.afjca.cci.IWAFInteraction.execute(IWAFInteraction.java:93)
    at com.iwaysoftware.iwae.common.JCATransport.execute(JCATransport.java:205)
    at com.iwaysoftware.iwae.common.AdapterClient.getTarget(AdapterClient.java:293)
    at com.ibi.bse.TargetWorker.run(TargetWorker.java:37)
    at java.lang.Thread.run(Thread.java:595)
    Help me

    I'm trying to create configure for JDE XE and 8.11 for Oracle AS for the integration with FMW. I finished configuring the JDE adapter, but while connecting JDE instances getting error in Application Explorer like, NumberFormat Exception as displayed in the question above.
    Can anyone tell please tell me where exactly I need to copy these .jar files from the JDE 8.11 as well as JDE XE. Actually I asked my JDE team to provide jar files to cinfigure the adapters and they are saying like they have multiple .jar files available across the folders.I have gone thru the docs but not sure where exactly the files to be copied. If I use different version the error changes to ArrayIndexOutOfBoundsException 0 > 0.
    For JDE XE connector.jar and kernel.jar
    and for 8.11 additional jdeutil.jar and log4j.jar.
    Please let me know where exactly the files to be copied.
    Thanks,
    Nirav

  • Invalid value

    Hi,
    I have the following actionListener with a numberformat exception, when an invalid value is entered into the textfield the exception is thrown but the program still takes the number an repaints the graphics. How do I make the program not do anything when an invalid number is entered.
    can anyone help?
    cheers
    void jTextField5_actionPerformed(ActionEvent e) {
        Float tempf = Float.valueOf(jTextField5.getText());
        f = tempf.floatValue();
        NumberFormatException df_g0_exception = new NumberFormatException("Invalid value");
        try
    if(Float.parseFloat(jTextField5.getText()) < 0)
            throw df_g0_exception;
    if(Float.parseFloat(jTextField5.getText()) > 100)
            throw df_g0_exception;
        catch(NumberFormatException nfex)
          //Error message if a number forma exception has occured
          JOptionPane.showMessageDialog(this,"enter number between 0 and 100","Number format exception",JOptionPane.WARNING_MESSAGE);
        calc();
        can.repaint();
      }

    You must do everything in the TRY statement. Thus calc(); and can.repaint(); must be called in the try. If a problem occurs the JVM gets out the Try and goes to the corresponding catch statement. In that case, the GUI is not refreshed.
    Try that!
    Hope it helps,
    STephane

Maybe you are looking for

  • Problems configuring HP Laserjet M1213nf MFP with Mac via AirPrint

    Hello, I have a HP Laserjet M1213nf MFP printer, connected to a Dlink DSL-2730U ADSL router. I am having problems configuring the printer with my Macbook running OSX Yosemite. I can see the printers name in nearby printers but when I try to add the p

  • Mastering Metadata in Lightroom 4

    I have hundreds of photos that I'm trying to adjust the date, location, comments, etc on. - Is there a why in lightroom to easily do this in list format? - When I view photos in windows explorer, metadata details will show up below in a bar with: Dat

  • Help! Apple repair in china really frustrating!

    i used Google translated this page(60-70% accurate): http://www.douban.com/group/topic/13659292/ i'll try to translate it more accurate here if i got time. 5 times before things change background http://www.douban.com/group/topic/13310753/ Now the la

  • IDOC field to SAP data base field

    Is there any way to find out the field names of SAP database table associated with the IDOC fields?? I would appreciate for any types of help in this. Pranav

  • Photo Collage - Which Product?

    Morning All! There was a special offer here with Groupon for printed canvasas, I've stocked up as there were a couple of images I always wanted blown up to +/- A1 size.  However, I bought more than I needed.  With the couple I have left, my plan is t