NumberFormatException: Infinite or NaN

I do some heavy calculations with lots of variables and formulars. Depending on the values, some other values (results) can get the value "NaN" or Infinite. At the end, I want to store the results in database and convert my doubles to BigDecimal objects. At this point I get such exceptions:
java.lang.NumberFormatException: Infinite or NaN
     at java.math.BigDecimal.<init>(BigDecimal.java:274)The only workaround i found so far, is to check each value via
            if (value1 == Double.NaN || value1 == Double.POSITIVE_INFINITY || value1 == Double.NEGATIVE_INFINITY) {
                value1 = 0.0;
            }And i have up to 30 values that can be NaN/Infinity. So, I'm looking for some other solution?

Well, I got a shorter form, but I hoped to somehow workaround this NaN/Infinity problem different:
        private final double resetNaN(double value) {
            double result = value;
            if (Double.isNaN(value) || Double.isInfinite(value)) {
                result = 0.0;
            return result;
        }//resetNaN()

Similar Messages

  • Failure to convert infinite double to BigDecimal

    I need to convert double to BigDecimal. But one of the double values is infinite and is not converted into the BigDecimal.
    I am getting this error.
    java.lang.NumberFormatException: Infinite or NaN.
    This is how I am converting it.
    private BigDecimal convert(Double object) {
    return new BigDecimal(object);
    Does anybody know how to do this?
    Thanks.

    caesarkim1 wrote:
    It seems to me that BigDecimal can't handle infinite number.Correct. As per the documentation in BigDecimal(double) and BigDecimal(String)
    BigDecimal(double)
    Throws: NumberFormatException - if val is infinite or NaN.
    BigDecimal(String)Translates the string representation of a BigDecimal into a BigDecimal. The string representation consists of an optional sign, '+' ('\u002B') or '-' ('\u002D'), followed by a sequence of zero or more decimal digits ("the integer"), optionally followed by a fraction, optionally followed by an exponent
    Throws: NumberFormatException - if val is not a valid representation of a BigDecimal

  • Topology Built from Spatial Geometries

    Hello, I am trying creating topology from example:
    CREATE TABLE city_streets6_geom ( -- City streets/roads
    name VARCHAR2(30) PRIMARY KEY,
    geometry SDO_GEOMETRY);
    CREATE TABLE traffic_signs6_geom ( -- Traffic signs
    name VARCHAR2(30) PRIMARY KEY,
    geometry SDO_GEOMETRY);
    CREATE TABLE land_parcels6_geom ( -- Land parcels
    name VARCHAR2(30) PRIMARY KEY,
    geometry SDO_GEOMETRY);
    INSERT INTO user_sdo_geom_metadata
    (TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES (
    'city_streets6_GEOM',
    'GEOMETRY',
    SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT('X', 0, 65, 0.005),
    SDO_DIM_ELEMENT('Y', 0, 45, 0.005)
    NULL -- SRID
    INSERT INTO user_sdo_geom_metadata
    (TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES (
    'traffic_signs6_GEOM',
    'GEOMETRY',
    SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT('X', 0, 65, 0.005),
    SDO_DIM_ELEMENT('Y', 0, 45, 0.005)
    NULL -- SRID
    INSERT INTO user_sdo_geom_metadata
    (TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES (
    'land_parcels6_GEOM',
    'GEOMETRY',
    SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT('X', 0, 65, 0.005),
    SDO_DIM_ELEMENT('Y', 0, 45, 0.005)
    NULL -- SRID
    -- Load these tables (names and geometries for city streets/roads,
    -- traffic signs, and land parcels).
    -- Insert data into city street line geometries.
    -- R1
    INSERT INTO city_streets6_geom VALUES('R1',
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
    SDO_ORDINATE_ARRAY(9,14, 21,14, 35,14, 47,14)));
    -- R2
    INSERT INTO city_streets6_geom VALUES('R2',
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
    SDO_ORDINATE_ARRAY(36,38, 38,35, 41,34, 42,33, 45,32, 47,28, 50,28, 52,32,
    57,33, 57,36, 59,39, 61,38, 62,41, 47,42, 45,40, 41,40)));
    -- R3
    INSERT INTO city_streets6_geom VALUES('R3',
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
    SDO_ORDINATE_ARRAY(9,35, 13,35)));
    -- R4
    INSERT INTO city_streets6_geom VALUES('R4',
    SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
    SDO_ORDINATE_ARRAY(25,30, 25,35)));
    -- Insert data into traffic sign point geometries.
    -- S1
    INSERT INTO traffic_signs6_geom VALUES('S1',
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(21,14,NULL), NULL, NULL));
    -- S2
    INSERT INTO traffic_signs6_geom VALUES('S2',
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(35,14,NULL), NULL, NULL));
    -- S3
    INSERT INTO traffic_signs6_geom VALUES('S3',
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(57,33,NULL), NULL, NULL));
    -- S4
    INSERT INTO traffic_signs6_geom VALUES('S4',
    SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(20,37,NULL), NULL, NULL));
    -- Insert data into land parcel polygon geometries.
    -- P1
    INSERT INTO land_parcels6_geom VALUES('P1',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
    SDO_ORDINATE_ARRAY(9,6, 21,6, 21,14, 21,22, 9,22, 9,14, 9,6)));
    -- P2
    INSERT INTO land_parcels6_geom VALUES('P2',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),
    SDO_ORDINATE_ARRAY(21,6, 35,6, 35,14, 35,22, 21,22, 21,14, 21,6)));
    -- P3
    INSERT INTO land_parcels6_geom VALUES('P3',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),
    SDO_ORDINATE_ARRAY(35,6, 47,6, 47,14, 47,22, 35,22, 35,14, 35,6)));
    -- P4
    INSERT INTO land_parcels6_geom VALUES('P4',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),
    SDO_ORDINATE_ARRAY(17,30, 31,30, 31,40, 17,40, 17,30)));
    -- P5 (polygon with a hole; exterior ring and one interior ring)
    INSERT INTO land_parcels6_geom VALUES('P5',
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1, 11,2003,1),
    SDO_ORDINATE_ARRAY(3,30, 16,30, 16,38, 3,38, 3,30, 4,31, 4,34, 7,34, 7,31, 4,31)));
    -- Validate the layers.
    create table val_results (sdo_rowid ROWID, result VARCHAR2(2000));
    call SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('city_streets6_GEOM','GEOMETRY','VAL_RESULTS');
    SELECT * from val_results;
    truncate table val_results;
    call SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('traffic_signs6_GEOM','GEOMETRY','VAL_RESULTS');
    SELECT * from val_results;
    truncate table val_results;
    call SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('land_parcels6_GEOM','GEOMETRY','VAL_RESULTS');
    SELECT * from val_results;
    drop table val_results;
    -- Create the spatial indexes.
    CREATE INDEX city_streets6_geom_idx ON city_streets6_geom(geometry)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    CREATE INDEX traffic_signs6_geom_idx ON traffic_signs6_geom(geometry)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    CREATE INDEX land_parcels6_geom_idx ON land_parcels6_geom(geometry)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    -- Start the main steps for using the topology data model with a
    -- topology built from Spatial geometry data.
    -- 1. Create the topology. (Null SRID in this example.)
    EXECUTE SDO_TOPO.CREATE_TOPOLOGY('CITY_DATA6', 0.00005);
    -- 2. Insert the universe face (F0). (id = -1, not 0)
    INSERT INTO CITY_DATA6_FACE$ values (
    -1, NULL, SDO_LIST_TYPE(), SDO_LIST_TYPE(), NULL);
    COMMIT;
    -- 3. Create feature tables.
    CREATE TABLE city_streets6 ( -- City streets/roads
    feature_name VARCHAR2(30) PRIMARY KEY,
    feature SDO_TOPO_GEOMETRY);
    CREATE TABLE traffic_signs6 ( -- Traffic signs
    feature_name VARCHAR2(30) PRIMARY KEY,
    feature SDO_TOPO_GEOMETRY);
    CREATE TABLE land_parcels6 ( -- Land parcels
    feature_name VARCHAR2(30) PRIMARY KEY,
    feature SDO_TOPO_GEOMETRY);
    -- 4. Associate feature tables with the topology.
    -- Add the three topology geometry layers to the CITY_DATA6 topology.
    -- Any order is OK.
    EXECUTE SDO_TOPO.ADD_TOPO_GEOMETRY_LAYER('CITY_DATA6', 'city_streets6', 'FEATURE','LINE');
    EXECUTE SDO_TOPO.ADD_TOPO_GEOMETRY_LAYER('CITY_DATA6', 'traffic_signs6','FEATURE', 'POINT');
    EXECUTE SDO_TOPO.ADD_TOPO_GEOMETRY_LAYER('CITY_DATA6', 'land_parcels6','FEATURE', 'POLYGON');
    -- As a result, Spatial generates a unique TG_LAYER_ID for each layer in
    -- the topology metadata (USER/ALL_SDO_TOPO_METADATA).
    -- 5. Create a TopoMap object and load the whole topology into cache for updating.
    EXECUTE SDO_TOPO_MAP.CREATE_TOPO_MAP('CITY_DATA6', 'CITY_DATA6_TOPOMAP');
    EXECUTE SDO_TOPO_MAP.LOAD_TOPO_MAP('CITY_DATA6_TOPOMAP', 'true');
    -- 6. Load feature tables, inserting data from the spatial tables and
    -- using SDO_TOPO_MAP.CREATE_FEATURE.
    BEGIN
    FOR street_rec IN (SELECT name, geometry FROM city_streets6_geom) LOOP
    INSERT INTO city_streets6 VALUES(street_rec.name,
    SDO_TOPO_MAP.CREATE_FEATURE('CITY_DATA6', 'city_streets6', 'FEATURE',
    street_rec.geometry));
    END LOOP;
    FOR sign_rec IN (SELECT name, geometry FROM traffic_signs6_geom) LOOP
    INSERT INTO traffic_signs6 VALUES(sign_rec.name,
    SDO_TOPO_MAP.CREATE_FEATURE('CITY_DATA6', 'traffic_signs6', 'FEATURE',
    sign_rec.geometry));
    END LOOP;
    FOR parcel_rec IN (SELECT name, geometry FROM land_parcels6_geom) LOOP
    INSERT INTO land_parcels6 VALUES(parcel_rec.name,
    SDO_TOPO_MAP.CREATE_FEATURE('CITY_DATA6', 'land_parcels6', 'FEATURE',
    parcel_rec.geometry));
    END LOOP;
    END;
    But process failed in sixth step with error:
    Error report:
    ORA-29532: java.lang.NumberFormatException: Infinite or NaN
    ORA-06512: line 3
    29532. 00000 - "Java call terminated by uncaught Java exception: %s"
    *Cause:    A Java exception or error was signaled and could not be
    resolved by the Java code.
    *Action:   Modify Java code, if this behavior is not intended.
    What should i do with this problem?
    Thanks

    thank you for reply.
    i can try to network topology.
    but i have more than one layer. for example lands, waters, etc.
    actually i need left face, right face, start node, end node etc. (topology info) information for my application.
    my question is on going...
    thanks for interest again

  • Test a double for NaN, Infinity or -Infinity

    Hello,
    My program uses JFreeChart library to plot a series of XY data plots.
    I Have some data that is loaded into an array from a tab delimited ASCII file supplyed by an ADC.
    Thats all good.
    I then take my data and calculate its gradient rather simply using dy/dx .... subseqent values of y divided by subsequent values of x
    This results in some gradients but also some NaNs and Infinities.
    I guess these come from where my data is doing : 0/n, or n/0
    When I try to plot the NaNs and Infinities my JFreeChart doesn't like it.
    How do I test for infinities or NaNs in my Array and deal with them?
    Here is some code that works but yields NaN and infinity values for some of the data:
            for(int i=0; i<StandardDevOfData.length ;i++)
                    double diffiny = (myData.get(i+length).getCurrent() - myData.get(i).getCurrent());
                    double diffinx = (myData.get(i+length).getPotential() - myData.get(i).getPotential());
                    double Gradient = (diffiny/diffinx);
                    StandardDevOfData[1]= Gradient;

    eenzc wrote:
    How do I test for infinities or NaNs in my Array[Double.isInfinite(double)|http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html#isInfinite(double)]
    and
    [Double.isNaN(double)|http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html#isNaN(double)]
    and deal with them?Depends. :)

  • Problems with convertNumber and Double values

    I've serious troubles using convertNumber with Double data in input fields.
    While output formatting works fine, the outputted string fails to be converted back - I get conversion errors.
    So the value that is written to the input field generates a conversion error being submitted! This is not good practice!
    I've found out the following: (I use german locale, so following examples containing ',' means decimal point)
    <f:convertNumber pattern="##0.00" />generates the right output, eg. for Double(20.50) - "20,50", but this value ("20,50") will not be parsed using the above pattern! Only values with non zero last minimum fractional digit (eg "20,51", "20,59", ... ) will be parsed!
    In addition, the above pattern doesn't parse numberstrings that don't contain all significant digits.
    For example an input of "20" will not be parsed to "20.00"!
    Maybe this is not the right forum for that problem, since i think this is a general java formatting problem (?).
    But as the problem arised by using the convertNumber tag and acting like this on numeric input fields is not very comfortable, I liked to post this here. Maybe someone can give me some advice?

    I also have found this problem, except that in my experience it is the decimal part that must be non-zero, not just the last digit of the decimal part. So with a pattern of "0.00" the string "1.50" (one and a half) will be accepted whereas the string "1.00" will not.
    My guess (just a guess) is that it is related to the documented behaviour of the DecimalFormat object when it parses a number. According to the documentation:
    The most economical subclass that can represent the number given by the string is chosen. Most integer values are returned as Long objects, no matter how they are written: "17" and "17.000" both parse to Long(17). Values that cannot fit into a Long are returned as Doubles. This includes values with a fractional part, infinite values, NaN, and the value -0.0. DecimalFormat does not decide whether to return a Double or a Long based on the presence of a decimal separator in the source string. Doing so would prevent integers that overflow the mantissa of a double, such as "10,000,000,000,000,000.00", from being parsed accurately. Currently, the only classes that parse returns are Long and Double, but callers should not rely on this. Callers may use the Number methods doubleValue, longValue, etc., to obtain the type they want.
    Which means that "1.50" will be returned as a Double while "1.00" will be returned as a Long. Perhaps there is then a class-cast exception whie trying to use this value?
    If this is indeed the problem, the solution is to use the getDouble() method of the parsed Number to create the Double to be returned, but this is for the implementer to do - not the user!

  • How to catch NaN, infinity errors?

    Example lets say i want to detect a NaN error
    when detected a error dialog appears
    taking this as an example
    String s;
            float Number;
            double Ans;
            s=txtNumber.getText();
            Number=Integer.parseInt(s);
            Ans= Number*2;
           s=String.valueOf(Math.toRadians(Ans));
          txtProduct.setText(s);
         } if ((Ans).equals("NaN"))
          if(true){
          JOptionPane.showMessageDialog(null,"Try Again.","Inane warning",JOptionPane.ERROR_MESSAGE);Can some1 tell me where i am wrong this works but for everything
    including Nan and Infinity i only want to detect NaN or Infinity
    now ive tried the second method isNaN and isInfinite
    if((double).IsNaN(Ans)); II .IsInfinite(Ans)
    if(true);  same as above public boolean failed to detect NaN or Infinity either returns true when its not false when its not
    with the dialog message keeps poping up
    and
    even with catch
    try{
    Ans=Number*2
    }catch (ArtithmeticException e) method the second and third dont give errors and they dont even detect NaN nor Infinite when the dialog is to show it doesn't
    ive tried this aswell
    if (txtProduct.setText(s).isNaN(Ans)){
    if(true){
    dialog should appear
    i get an error saing double or float or void cannot be differenced
    im posting this here for the experts who can figure this out
    try test the simple code before i could work and implement a more complex one later
    your help on this one
    thanks
    Edited by: AK-Emm on Sep 5, 2008 7:29 PM

    AK-Emm wrote:
    float Number;
    double Ans;
    Number=Integer.parseInt(s);
    Ans= Number*2;
    if ((Ans).equals("NaN"))
    You have an integer, which you convert to a float and then a double. You then check if it is NaN. There are no integer values for which this sequence of operations will produce a NaN.
    Are you coming from working in a language where 'NaN' is used to signify that parsing the string failed? In Java, the method throws NumberFormatException rather than returning NaN. This is done so that client code is simplified as the error handling is separate from the main flow, because NaN is a double not an int and Java is mostly strongly typed, and because Double.parseDouble("NaN") should return NaN without it being an error.

  • Inconsistent Floating Point Math and NaNs on Windows Laptops?

    All -
    I am seeing some very strange inconsistent floating point calculations on Windows Laptops, and I am wondering if anyone has any ideas. Read on, as (to me!) it's very interesting....
    I have attached a segment of our code, along with some sample output. Looking at the code and the output, it seems like it's totally impossible.
    With supposedly non-NaN and non-infinite double values, I am seeing unrepeatable and inconsistent math - the below example only illustrates one such case where we're seeing this behavior.
    If you look at the code below, you will see that I do things like:
    double rhoYo = ...  // some math
    double rho = ...  // exact same mathStrangely enough, I might get rhoYo = 1.51231231 etc and rho = NaN.
    If I reverse those lines (vertically), then again, rhoYo comes out good and rho comes out NaN; however, this is unpredictable and inconsistent. If I project a source point, get a destination point with NaNs as a result, and project the source again, the second destination point may be just fine. Matter of fact, i can put a loop in the code such as:
          double rho = Double.NaN;
          for( int i = 0; i < 10; i++ )
            rho = my_earthRad * my_F / Math.pow(Math.tan(Math.PI/4.0 + latRad/2.0), my_n);
            if( ! Double.isNaN( rho ) )
              break;
            System.out.println("NaN'ed rho");
          }and rho will eventually become non-NaN (random # of iterations)!!
    How's that possible? Our code might be tromping on memory somewhere, but this sure seems crazy to me, especially considering that
    we're only using local variables. Anyone know of floating point errors on Windows Laptops?
    With the exact same codebase, this behavior ONLY happens on Windows Laptops, including brand new Dells, old Dells, IBM, Intel and AMD chips (I've tried several ;-). It does NOT happen on Mac or Linux, including the Linux side of a Linux/Windows dual-boot (where it does happen with the Windows side). Even more strangely, it does NOT happen with Windows desktops. I have tried several 1.5.x JVMs, webstart vs no webstart, etc, to no avail. Always and only on Windows Laptops.
    Please help.... ;-) and thanks in advance.
    Sample code:
    public class Projection
      protected Point2D.Double _project(Point2D.Double srcPt, Point2D.Double dstPt) {
        final double my_degToRad = Math.PI / 180.0;
        final double my_originLon = -95.0;
        final double my_originLonRad = my_originLon * my_degToRad;
        final double my_originLat = 25.0;
        final double my_originLatRad = my_originLat * my_degToRad;;
        final double my_stdLat1 = 25.0;
        final double my_stdLat1Rad = my_stdLat1 * my_degToRad;
        final double my_earthRad = 6371.2;
        final double my_n = Math.sin( my_stdLat1Rad );
        final double my_F = Math.cos( my_stdLat1Rad ) * Math.pow( Math.tan( Math.PI / 4.0 + my_stdLat1Rad / 2.0 ), my_n ) / my_n;
        final double my_rhoZero = my_earthRad * my_F / Math.pow( Math.tan( Math.PI / 4.0 + my_originLatRad / 2.0 ), my_n );
        if ( Double.isNaN( my_n ) || Double.isNaN( my_F ) || Double.isNaN( my_rhoZero )) {
          return new Point2D.Double(Double.NaN, Double.NaN);
        if( Double.isNaN( srcPt.x ) || Double.isNaN( srcPt.y ) )
            System.out.println("======= _project received a srcPt with NaNs. Returning NaN point.");
            Point2D.Double nanPoint = new Point2D.Double();
            nanPoint.x = nanPoint.y = Double.NaN;
            return nanPoint;
        if( Double.isInfinite( srcPt.x ) || Double.isInfinite( srcPt.y ) )
            System.out.println("======= _project received a srcPt with isInfinite. Returning NaN point.");
            Point2D.Double nanPoint = new Point2D.Double();
            nanPoint.x = nanPoint.y = Double.NaN;
            return nanPoint;
        //  Inputs are lon, lat degrees.
        final double lonRad = srcPt.x * my_degToRad;
        final double latRad = srcPt.y * my_degToRad;
        final double theta = my_n * (lonRad - my_originLonRad);
        // One Std lat -- tangential cone.
        final double rhoYo = my_earthRad * my_F / Math.pow(Math.tan(Math.PI/4.0 + latRad/2.0), my_n);
        final double rho   = my_earthRad * my_F / Math.pow(Math.tan(Math.PI/4.0 + latRad/2.0), my_n);
        // Computes kilometers in lambert space.
        dstPt.x = rho * Math.sin(theta);
        dstPt.y = my_rhoZero - (rho * Math.cos(theta));
        // WANK - Here's the problem!  These values shouldnt be NaN!
        if( Double.isNaN( dstPt.x ) || Double.isNaN( dstPt.y ) )
            System.out.println("======= A _projected dstPt has NaNs. Dumping...vvvvvvvvvvvvvvvvvvvvvvvvvvvv");
            if( Double.isNaN( dstPt.x ) )
                System.out.println("======= dstPt.x is NaN");
            if( Double.isNaN( dstPt.y ) )
                System.out.println("======= dstPt.y is NaN");
            System.out.println("======= my_stdLat1 = " + my_stdLat1 );
            System.out.println("======= my_n = " + my_n );
            System.out.println("======= my_originLonRad = " + my_originLonRad );
            System.out.println("======= my_F = " + my_F );
            System.out.println("======= my_earthRad = " + my_earthRad );
            System.out.println("======= lonRad = " + lonRad );
            System.out.println("======= latRad = " + latRad );
            System.out.println("======= theta = " + theta );
            System.out.println("======= Math.tan(Math.PI/4.0 + latRad/2.0) = " + Math.tan(Math.PI/4.0 + latRad/2.0) );
            System.out.println("======= Math.pow(Math.tan(Math.PI/4.0 + latRad/2.0), my_n) = " + Math.pow(Math.tan(Math.PI/4.0 + latRad/2.0), my_n) );
            System.out.println("======= rho = " + rho );
            System.out.println("======= rhoYo = " + rhoYo );
            System.out.println("======= Math.sin(theta) = " + Math.sin(theta) );
            System.out.println("======= dstPt.x = " + dstPt.x );
            System.out.println("======= Math.cos(theta) = " + Math.cos(theta) );
            System.out.println("======= my_rhoZero = " + my_rhoZero );
            System.out.println("======= (rhoYo * Math.cos(theta)) = " + (rho * Math.cos(theta)) );
            System.out.println("======= my_rhoZero - (rhoYo * Math.cos(theta)) = " + (my_rhoZero - (rho * Math.cos(theta)) ));
            System.out.println("======= dstPt.y = " + dstPt.y );
            System.out.println("======= A _projected dstPt had NaNs. Done dumping. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
        return dstPt;
    }And here's the sample output:
    ======= A _projected dstPt has NaNs. Dumping...vvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ======= dstPt.x is NaN
    ======= dstPt.y is NaN
    ======= my_stdLat1 = 25.0
    ======= my_n = 0.42261826174069944
    ======= my_originLonRad = -1.6580627893946132
    ======= my_F = 2.5946660025799146
    ======= my_earthRad = 6371.2
    ======= lonRad = -2.7564670759053924
    ======= latRad = 0.3730758324037379
    ======= theta = -0.4642057102537187
    ======= Math.tan(Math.PI/4.0 + latRad/2.0) = 1.4652768116539785
    ======= Math.pow(Math.tan(Math.PI/4.0 + latRad/2.0), my_n) = 1.175224090766834
    ======= rho = NaN
    ======= rhoYo = 14066.369269924155
    ======= Math.sin(theta) = -0.44771270676160557
    ======= dstPt.x = NaN
    ======= Math.cos(theta) = 0.8941774612481554
    ======= my_rhoZero = 13663.082491950498
    ======= (rhoYo * Math.cos(theta)) = NaN
    ======= my_rhoZero - (rhoYo * Math.cos(theta)) = NaN
    ======= dstPt.y = NaN
    ======= A _projected dstPt had NaNs. Done dumping. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    HI JSchell (and others?) -
    I have created a simple example attached below, that when run repeatedly, does indeed generate spurious NaNs. I have made it as simple as possible. In the code, I use my own lon/lat binary data file, though I am sure any will do. Let me know if anyone wants that file.
    So the deal is that (with my data at least) this program should never generate NaN results. And if one runs it 25432 (eg: random #) times, it wont, but then the 25433th time, it will create NaNs, etc. ie: inconsistent NaN math results.
    As I said before, I have run this on old and new Dell laptops under Windows XP, using java 1.5_02, 1.5_04 and 1.5_08. The latest run was on a brand new Dell with a Intel Core Duo T2600 processor, running XP. If this is a result of the Pentium bug, one would think that would be fixed by now. I have NOT yet tested on AMD, though I will do that this afternoon.
    Remember, this ONLY happens with Windows Laptops.
    Any ideas anyone? Thanks in advance ;-)
    Here's the code that produces spurious NaNs:
    import java.awt.geom.Point2D;
    import java.io.DataInputStream;
    import java.io.EOFException;
    import java.io.File;
    import java.io.FileInputStream;
    public class FloatingPointTest2 implements Runnable
      private static final int NUM_ITERATIONS = 100000;
      private double _degToRad = Math.PI / 180.0;
      private double _originLon = -95.0;
      private double _originLat = 25.0;
      private double _originLonRad = _originLon * _degToRad;
      private double _originLatRad = _originLat * _degToRad;;
      private double _stdLat1 = 25.0;
      private double _stdLat1Rad = _stdLat1 * _degToRad;
      private double _earthRad = 6371.2;
      private double _n = _n = Math.sin( _stdLat1Rad );
      private double _F = Math.cos( _stdLat1Rad ) * Math.pow( Math.tan( Math.PI / 4.0 + _stdLat1Rad / 2.0 ), _n ) / _n;
      private double _rhoZero = _earthRad * _F / Math.pow( Math.tan( Math.PI / 4.0 + _originLatRad / 2.0 ), _n );
      private Point2D.Double _project( Point2D.Double srcPt, Point2D.Double dstPt )
        if( Double.isNaN( srcPt.x ) || Double.isNaN( srcPt.y ) )
          System.out.println( "FloatingPointTest2: received a NaN srcPt.  Skipping." );
          return new Point2D.Double( Double.NaN, Double.NaN );
        //  Inputs are lon, lat degrees.
        final double lonRad = srcPt.x * _degToRad;
        final double latRad = srcPt.y * _degToRad;
        final double theta = _n * ( lonRad - _originLonRad );
        double rho = _earthRad * _F / Math.pow( Math.tan( Math.PI / 4.0 + latRad / 2.0 ), _n );
        dstPt.x = rho * Math.sin( theta );
        dstPt.y = _rhoZero - ( rho * Math.cos( theta ) );
        return dstPt;
      public void doTest()
        DataInputStream instream = null;
        int thisRunNaNCount = 0;
        Point2D.Double tempPt = new Point2D.Double();
        Point2D.Double dstPt = new Point2D.Double();
        try
          instream = new DataInputStream( new FileInputStream( System.getProperty(
            "user.home" ) + File.separatorChar + "lonLatBinaryData.bin" ) );
          try
            while( true )
              double lon = instream.readDouble();
              double lat = instream.readDouble();
              if( Double.isNaN( lon ) || Double.isNaN( lat ) )
                continue;
              tempPt.x = lon;
              tempPt.y = lat;
              dstPt = _project( tempPt, dstPt );
              if( Double.isNaN( dstPt.x ) || Double.isNaN( dstPt.y ) )
                thisRunNaNCount++;
          catch( EOFException e )
    //        System.out.println( "End of file" );
          if( thisRunNaNCount > 0 )
            System.out.println( "thisRunNaNCount = " + thisRunNaNCount );
          instream.close();
        catch( Exception e )
          e.printStackTrace();
          System.exit( 1 );
      public void run()
        doTest();
      public static void main( String args[] )
        System.out.println( "Executing FloatingPointTest2." );
        for( int i = 0; i < NUM_ITERATIONS; i++ )
          FloatingPointTest2 test = new FloatingPointTest2();
          test.doTest();
    }

  • Automatic trapping of NaNs?

    Infinites would be nice too.
    I badly need a way to force the JVM to automatically throw an Exception with the first occurence of a numerical error. Yes, debugging is possible by throwing in if(X!=X) type statements, but the time expended to locate problems is enormous in a large program. I guess there are some other alternatives: 1) Stop making programming errors. 2) Run a Java to C++ converter and then turn on NaN trapping in the C++ loader, ... How about a Java option?
    Thanks.

    How about 200,000 lines of code and >1 hour for a
    test case. You can't have a 200,000 line method so presumably you have more than one method.
    Each method can have a NAN check at the end.
    Adding in a few strategic NaN checks can
    make this >2 hours for a test case. Then 1 or more of the following is true...
    - The checks are creationg 1000s/10000s of exceptions (because you are producing too many NANs anyways.)
    - It isn't a "simple" check that is being added.
    - Something is really wrong with the code.
    We are very good
    at putting in NaN checks, but the lack of an
    automatic NaN trapping capability has still set the
    overall project back several months.Java has always been that way. So that suggests the architecture/design was flawed from the beginning (because either the wrong language was choosen or the attributes of the language were ignored.)
    Actually I believe C++ behaves that way as well. (At least I have used compilers that did that.)
    You can of course modify the JVM. If might take months however to figure out where to modify it. And if you distribute the code you will need a contract with Sun.

  • SQL stored procedure Staging.GroomDwStagingData stuck in infinite loop, consuming excessive CPU

    Hello
    I'm hoping that someone here might be able to help or point me in the right direction. Apologies for the long post.
    Just to set the scene, I am a SQL Server DBA and have very limited experience with System Centre so please go easy on me.
    At the company I am currently working they are complaining about very poor performance when running reports (any).
    Quick look at the database server and CPU utilisation being a constant 90-95%, meant that you dont have to be Sherlock Holmes to realise there is a problem. The instance consuming the majority of the CPU is the instance hosting the datawarehouse and in particular
    a stored procedure in the DWStagingAndConfig database called Staging.GroomDwStagingData.
    This stored procedure executes continually for 2 hours performing 500,000,000 reads per execution before "timing out". It is then executed again for another 2 hours etc etc.
    After a bit of diagnosis it seems that the issue is either a bug or that there is something wrong with our data in that a stored procedure is stuck in an infinite loop
    System Center 2012 SP1 CU2 (5.0.7804.1300)
    Diagnosis details
    SQL connection details
    program name = SC DAL--GroomingWriteModule
    set quoted_identifier on
    set arithabort off
    set numeric_roundabort off
    set ansi_warnings on
    set ansi_padding on
    set ansi_nulls on
    set concat_null_yields_null on
    set cursor_close_on_commit off
    set implicit_transactions off
    set language us_english
    set dateformat mdy
    set datefirst 7
    set transaction isolation level read committed
    Store procedures executed
    1. dbo.p_GetDwStagingGroomingConfig (executes immediately)
    2. Staging.GroomDwStagingData (this is the procedure that executes in 2 hours before being cancelled)
    The 1st stored procedure seems to return a table with the "xml" / required parameters to execute Staging.GroomDwStagingData
    Sample xml below (cut right down)
    <Config>
    <Target>
    <ModuleName>TransformActivityDim</ModuleName>
    <WarehouseEntityName>ActivityDim</WarehouseEntityName>
    <RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
    <Watermark>2015-01-30T08:59:14.397</Watermark>
    </Target>
    <Target>
    <ModuleName>TransformActivityDim</ModuleName>
    <WarehouseEntityName>ActivityDim</WarehouseEntityName>
    <RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
    <ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName>
    <Watermark>2015-01-30T08:59:14.397</Watermark>
    </Target>
    </Config>
    If you look carefully you will see that the 1st <target> is missing the ManagedTypeViewName, which when "shredded" by the Staging.GroomDwStagingData returns the following result set
    Example
    DECLARE @Config xml
    DECLARE @GroomingCriteria NVARCHAR(MAX)
    SET @GroomingCriteria = '<Config><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><Watermark>2015-01-30T08:59:14.397</Watermark></Target><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName><Watermark>2015-01-30T08:59:14.397</Watermark></Target></Config>'
    SET @Config = CONVERT(xml, @GroomingCriteria)
    SELECT
    ModuleName = p.value(N'child::ModuleName[1]', N'nvarchar(255)')
    ,WarehouseEntityName = p.value(N'child::WarehouseEntityName[1]', N'nvarchar(255)')
    ,RequiredWarehouseEntityName =p.value(N'child::RequiredWarehouseEntityName[1]', N'nvarchar(255)')
    ,ManagedTypeViewName = p.value(N'child::ManagedTypeViewName[1]', N'nvarchar(255)')
    ,Watermark = p.value(N'child::Watermark[1]', N'datetime')
    FROM @Config.nodes(N'/Config/*') Elem(p)
    /* RESULTS - NOTE THE NULL VALUE FOR ManagedTypeViewName
    ModuleName WarehouseEntityName RequiredWarehouseEntityName ManagedTypeViewName Watermark
    TransformActivityDim ActivityDim MTV_System$WorkItem$Activity NULL 2015-01-30 08:59:14.397
    TransformActivityDim ActivityDim MTV_System$WorkItem$Activity MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity 2015-01-30 08:59:14.397
    When the procedure enters the loop to build its dynamic SQL to delete relevant rows from the inbound schema tables it concatenates various options / variables into an executable string. However when adding a NULL value to a string the entire string becomes
    NULL which then gets executed.
    Whilst executing "EXEC(NULL)" would cause SQL to throw an error and be caught, executing the following doesnt
    DECLARE @null_string VARCHAR(100)
    SET @null_string = 'hello world ' + NULL
    EXEC(@null_string)
    SELECT @null_string
    So as it hasnt caused an error the next part of the procedure is to move to the next record and this is why its caught in an infinite loop
    DELETE @items WHERE ManagedTypeViewName = @View
    The value for the variable @View is the ManagedTypeViewName which is NULL, as ANSI_NULLS are set to ON in the connection and not overridded in the procedure then the above statement wont delete anything as it needs to handle NULL values differently (IS NULL),
    so we are now stuck in an infinite loop executing NULL for 2 hours until cancelled.
    I amended the stored procedure and added the following line before the loop statement which had the desired effect and "fixed" the performance issue for the time being
    DELETE @items WHERE ManagedTypeViewName IS NULL
    I also noticed that the following line in dbo.p_GetDwStagingGroomingConfig is commented out (no idea why as no notes in the procedure)
    --AND COALESCE(i.ManagedTypeViewName, j.RelationshipTypeViewName) IS NOT NULL
    There are obviously other ways to mitigate the dynamic SQL string being NULL, there's more than one way to skin a cat and thats not why I am asking this question, but what I am concerned about is that is there a reason that the xml / @GroomingCriteria is incomplete
    and / or that the procedures dont handle potential NULL values.
    I cant find any documentation, KBs, forum posts of anyone else having this issue which somewhat surprises me.
    Would be grateful of any help / advice that anyone can provide or if someone can look at their 2 stored procedures on a later version to see if it has already been fixed. Or is it simply that we have orphaned data, this is the bit that concerns most as I dont
    really want to be deleting / updating data when I have no idea what the knock on effect might be
    Many many thanks
    Andy

    First thing I would do is upgrade to 2012 R2 UR5. If you are running non-US dates you need the UR5 hotfix also.
    Rob Ford scsmnz.net
    Cireson www.cireson.com
    For a free SCSM 2012 Notify Analyst app click
    here

  • Java.lang.NumberFormatException: For input string: "DESCRIPTION="

    Colleagues,
    eBis 11.5.10.2.
    I'm getting a Warning in the concurrent manager when I submit a programme that has an attached xml template. The warning is stating: -
    ------------- 1) PUBLISH -------------
    Beginning post-processing of request 2667735 on node BAMBI at 02-SEP-2011 17:32:56.
    Post-processing of request 2667735 failed at 02-SEP-2011 17:32:57 with the error message:
    One or more post-processing actions failed. Consult the OPP service log for details.
    ------------- 2) PRINT   -------------
    Not printing the output of this request because post-processing failed.
    When I consult the OPP log in Sysadmin, I can see a not very helpful message: -
    [9/2/11 5:32:57 PM] [UNEXPECTED] [36822:RT2667735] java.lang.NumberFormatException: For input string: "DESCRIPTION="
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         at java.lang.Integer.parseInt(Integer.java:447)
         at java.lang.Integer.parseInt(Integer.java:497)
         at oracle.apps.xdo.generator.pdf.PDFGenerator.setFont(PDFGenerator.java:629)
         at oracle.apps.xdo.generator.pdf.PDFGenerator.setProperties(PDFGenerator.java:468)
         at oracle.apps.xdo.generator.ProxyGenerator.setProperties(ProxyGenerator.java:1373)
         at oracle.apps.xdo.template.fo.FOHandler.startElement(FOHandler.java:262)
         at oracle.apps.xdo.template.fo.FOHandler.startElement(FOHandler.java:204)
         at oracle.apps.xdo.common.xml.XSLTMerger.startElement(XSLTMerger.java:55)
         at oracle.xml.parser.v2.XMLContentHandler.startElement(XMLContentHandler.java:167)
         at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1182)
         at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:301)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:149)
         at oracle.apps.xdo.template.fo.FOProcessingEngine.process(FOProcessingEngine.java:320)
         at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:1051)
         at oracle.apps.xdo.oa.schema.server.TemplateHelper.runProcessTemplate(TemplateHelper.java:5926)
         at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3458)
         at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3547)
         at oracle.apps.fnd.cp.opp.XMLPublisherProcessor.process(XMLPublisherProcessor.java:290)
         at oracle.apps.fnd.cp.opp.OPPRequestThread.run(OPPRequestThread.java:157)
    [9/2/11 5:32:57 PM] [36822:RT2667735] Completed post-processing actions for request 2667735.
    Now, this isn't programme specific as it's affecting all our BI Publisher reports. Also the specific report I am working on has the option to email. I'm finding that the emails still work and when I open the attachment, they are displaying in PDF format correctly - even though the concurrent manager completes with the above warning. The above warning doesn't let me view the output in PDF from Oracle Financials.
    Any help would be greatly appreciated.
    Thanks

    Maybe check if Metalink note 764180.1 applies? This appears to be a bug fixed with patch 7669965.

  • Jsp throw numberformatexception.see my code .reply as soon as possible

    i am developed application onclick checkbox delete the record.on first field i give the href to serailno for open the update page. like this <a href="UpdateBoq.jsp?S_NO=<%=sno%>">.sno is serialno.is come from database wihen i am click on serial no it show the updatepage.jsp is not open the updatepage.jsp but it throw the exception number format.this is my code.anybody help me this my project working i am only the single persion to develop this application in jsp.please help me.as soon as possible
    <%@ page language="java" import="java.sql.*"%>
    <%@ page import="java.text.SimpleDateFormat" %>
    <%@ page import="java.util.Date" %>
    <%! int count = 0; %>
    <%! String itemcode;%>
    <%! String sns;%>
    <%! String contunit; %>
    <%! float qty; %>
    <%! float oup;%>
    <%! float oep;%>
    <%! int sno;%>
    <%! int stcode;%>
    <%! float sum=0.0f;%>
    <%! float sum1=0.0f;%>
    <jsp:useBean id="sos" class="boq.Calculation" scope="request"/>
    <%
    //String userID = String.valueOf(session.getAttribute("APP_USER_ID"));
    //String userID = String.valueOf(session.getAttribute("LOGIN_ID"));
    String strDelete = request.getParameter("btnDelete");
    String strserialno=request.getParameter("serialno1");
    String strmopno = request.getParameter("mop");
    String strjobno = request.getParameter("job");
    String strwop=request.getParameter("siten");
    String strno=request.getParameter("siteno");
    if (strDelete != null)
    String del=request.getParameter("hidcount");
    int delcount=-1;
    if (del!=null)
    System.out.println("I am in start of delete Action");
    delcount = Integer.parseInt(del);
    String strCheckBox="";
    String strHidVal="";
    for (int i=0; i<=delcount; i++)
    strCheckBox = request.getParameter("checkbox"+i);
    if(strCheckBox!=null)
    strHidVal = request.getParameter("hid"+i);
    System.out.println("country code is :"+strHidVal);
    System.out.println(del);
    Connection con=null;
    try
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.87:1521:orcl","system","tiger");
    System.out.println(con);
    Statement st2 = con.createStatement();
    Statement st1 = con.createStatement();
    String str0="select * from BOQ where S_NO= '"+ strHidVal + "'";
    ResultSet rs = st1.executeQuery(str0);
    String str="delete from BOQ where S_NO= '"+ strHidVal + "'";
    System.out.println(strCheckBox);
    int a=st2.executeUpdate(str);
    catch(Exception e)
    %>
    <script language="JavaScript">
    alert("<%=e.getMessage()%>");
    </script>
    <%
    finally
    if(con!=null)
    con.close();
    %>
    <html>
    <head>
    <title>CRS</title>
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
    <link rel="stylesheet" href="css/ems.css" type="text/css">
    </HEAD>
    <body leftmargin=0 topmargin=2>
    <jsp:include page="Index.html" />
    <form name=form1 action="BOQVIEW.jsp" method=post>
    <table border=0 cellspacing=1 cellpadding=1 width=100% height=5>
    <tr>
    <td valign="top" height="23">
    <table width="100%" border="0" cellspacing="1" cellpadding="1">
    <tr>
    <td bgcolor='#E6E4E4' width=45 align="Center" colspan=2>
    <font color="#5d7a80" size="2">
    BOQ OF MOPS
    </font>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td valign=top>
    <table width="100%" cellpadding="1" cellspacing="1" border="0">
    <tr>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=40>S/NO</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=60>SITE NAME</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=65>SITE NUMBER</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=90>ITEM CODE/MATERIAL CODE</td>
    <td width="180" height="5" class="ReportColumnHeader" align="center"colspan=120>CONTRACT UNIT DESCRIPTION ORIGINAL</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=>QUANTITY</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=90 >ORIGINAL UNIT PRICE</td>
    <td width="130" height="5" class="ReportColumnHeader" align="center" colspan=100>ORIGINAL EXTENDED PRICE</td>
    </tr>
    </table>
    <%
    Connection con=null;
    try
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","tiger");
    System.out.println(con);
    Statement st = con.createStatement();
    Statement st1=con.createStatement();
    String qoq=request.getParameter("qoq");
    int one=Integer.parseInt(qoq);
    ResultSet rs = st.executeQuery("SELECT * from BOQ where SITE_CODE="+one);
    ResultSet rs1=st1.executeQuery("select SUM(O_U_P) AS oriunitprice,SUM(O_E_P) AS oriextendsprice from boq WHERE SITE_CODE="+one);
    %>
    <%
    int count=0;
    while(rs.next())
    sno=rs.getInt(1);
    stcode=rs.getInt(2);
    sns=rs.getString(3);
    itemcode=rs.getString(4);
    contunit = rs.getString(5);
    qty=rs.getFloat(6);
    oup = rs.getFloat(7);
    oep = rs.getFloat(8);
    %>
    <table border="0" cellspacing="1" cellpadding="1" width="100" >
    <tr>
    <td class="ReportCellText1" width="10" height=><input type=checkbox name="<%="checkbox"+count%>" onselect="deleterecord();"> </td>
    <td class="ReportCellText1" width="130" height="5" align="center" colspan=29><a href="UpdateBoq.jsp?S_NO=<%=sno%>"><%=sno%></a>
    </td>
    <td class="ReportCellText1" width="55" height="5" align="center" COLSPAN=60><%=sns%></td>
    <td class="ReportCellText1" width="50" height="5" align="center" COLSPAN=65><%=stcode%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" COLSPAN=90><%=itemcode%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" COLSPAN=120><%=contunit%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" COLSPAN=54><%=qty%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" COLSPAN=90><%=oup%></td>
    <td class="ReportCellText1" width="130" height="5" align="center" colspan=100> <%=oep%></td>
    </tr>
    <tr>
    </table>
    <input type=hidden name="<%="hid"+count%>" value="<%=sno%>">
    <!--
    </tr>
    <tr>
    </tr>
    <tr>
    </tr> !-->
    <%
    count++;
    %>
    <table width="100%" cellpadding="1" cellspacing="1" border="0">
    <TR>
    <td width="60" height="5" class="ReportCellText3" align="center" colspan=></td>
    <td class="ReportCellText3" width="55" height="5" align="center" COLSPAN=></td>
    <td width="60" height="5" class="ReportCellText3" align="center" colspan=></td>
    <td class="ReportCellText3" width="50" height="5" align="center" COLSPAN=></td>
    <td class="ReportCellText3" width="50" height="5" align="center" COLSPAN=></td>
    <td class="ReportCellText3" width="50" height="5" align="center" COLSPAN=></td>
    <td class="ReportCellText3" width="50" height="5" align="center" COLSPAN=></td>
    <%
    rs1.next();
    sum=rs1.getFloat("oriunitprice");
    sum1=rs1.getFloat("oriextendsprice");
    %>
    <td width="60" height="5" class="ReportColumnHeader" align="center" colspan=>TOTLE AMOUNT</td>
    <td class="ReportCellText1" width="85" height="5" align="center" colspan=> <%=sum%></td>
    <td class="ReportCellText1" width="90" height="5" align="center" colspan=> <%=sum1%></td>
    </table>
    <TABLE>
    <input type=hidden name=hidcount value =<%=count%>>
    <input type=hidden name=serialno value=<%=itemcode%>>
    <INPUT TYPE=hidden NAME=mop VALUE=<%=contunit%> >
    <INPUT TYPE=hidden NAME=job VALUE=<%=qty%> >
    <INPUT TYPE=HIDDEN name=siten value=<%=oup%>>
    <input type=hidden name=siteno value=<%=oep%>>
    <table><tr><td>
    <input type = button value = Print size=20 onClick = "window.print();"></td>
    <td><input type = Submit value = "Delete" name="btnDelete" size = 20> </td>
    </form>
    <form action=BOQ.jsp method=post>
    <td><input type=Submit value = "Add New" size=20></td>
    </form>
    <form action=NEWPEexl.jsp method=post>
    <td><input type=Submit value = "Export to Excel" size=20></td></tr></table>
    </form>
    <%
    catch(Exception e)
    out.println(e.getMessage());
    finally
    if(con!=null)
    con.close();
    %>
    </body>
    </html>
    when i am click the serial no it show the update page is update .jsp
    this is the update code
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld"
    prefix="fileaccess"%>
    <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/sqltaglib.tld"
    prefix="database"%>
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page language="java" import="java.sql.,java.util."%>
    <%@ page import="java.text.SimpleDateFormat" %>
    <%@ page import="java.util.Date" %>
    <%! int count = 0; %>
    <%!Connection con=null;%>
    <%!PreparedStatement ps=null;%>
    <%
    String strUpdate = request.getParameter("btnUpdate");
    String sno=request.getParameter("serialno1");
    int snoi=Integer.parseInt(request.getParameter("serialno1"));
    String sc=request.getParameter("sitenumber");
    int sci=Integer.parseInt(request.getParameter("sitenumber"));
    String sn=request.getParameter("sitename");
    String itc=request.getParameter("itemno");
    String cu=request.getParameter("contract");
    String qty=request.getParameter("quantity");
    float qtyf=Float.parseFloat(request.getParameter("quantity"));
    String oup=request.getParameter("orig");
    float oupf=Float.parseFloat(request.getParameter("orig"));
    String oep=request.getParameter("origexp");
    float oepf=Float.parseFloat(request.getParameter("origexp"));
    if (strUpdate != null)
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.87:1521:orcl","system","tiger");
    System.out.println(con);
    System.out.println("Connection Established");
    Statement st = con.createStatement();
    String str="update BOQ set SITE_CODE="sci",SITE_NAME='"sn"',ITEM_CODE='"itc"',CONTRACT_UNIT='"cu"',QTY="qtyf",O_U_P="oupf",O_E_P="oepf" where S_NO="snoi" ";
    int a=st.executeUpdate(str);
    if (a>0)
    %>
    <script type="text/javascript" >
    alert("The Record has been Updated Successfully");
    <% response.sendRedirect("BOQVIEW.jsp"); %>
    </script>
    <%
    catch(Exception e)
    String m = e.getMessage();
    %>
    <font size="1" face="Verdana" color=blue>
    "<%=m%>"</font>
    <%
    try
    if(con!=null)
    con.close();
    catch(SQLException sq)
    out.println(sq.getMessage());
    %>
    <!-- Insert the data code-->
    <HTML>
    <head>
    <title>BOQ</title>
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
    <script type="text/javascript">
    function callingdate()
    Calendar.setup({
    inputField : "f_date_b", //*
    ifFormat : "%d-%b-%Y ",
    showsTime : true,
    button : "f_trigger_b", //*
    step : 1
    function callingdate1()
    Calendar.setup({
    inputField : "f_date_b1", //*
    ifFormat : "%d-%b-%Y ",
    showsTime : true,
    button : "f_trigger_b1", //*
    step : 1
    function dating()
    var mylist=document.getElementById("effective_date")
    document.getElementById("date").value=mylist.options[mylist.selectedIndex].text
    function caps() {
    document.form1.country_code.value = document.form1.country_code.value.toUpperCase()
    document.form1.country_name.value = document.form1.country_name.value.toUpperCase()
    </script>
    </head>
    <BODY >
    <% count++;
    %>
    <form name=form1 action=UpdateBoq.jsp method=post>
    <!-- <h3 STYLE = "BACKGROUND-COLOR=blue;
    COLOR=YELLOW"
    align=center color=green>Country Information</h1> !-->
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td bgcolor='#336699' align="Center"><font color="#d2b48c" size=2>BOQ OF MOPS</font> </td>
    </tr>
    </table>
    <%
    Connection con=null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.87:1521:orcl","system","tiger");
    System.out.println(con);
    Statement st = con.createStatement();
    String se=request.getParameter("serialno1");
    //int ser=Integer.parseInt(request.getParameter("serialno1"));
    String s="SELECT * from BOQ where S_NO="Integer.parseInt(request.getParameter("serialno1"))" ";
    ResultSet rs = st.executeQuery(s);
    System.out.println(s);
    %>
    <%
    while(rs.next())
    int serialno=rs.getInt(1);
    int stcode=rs.getInt(2);
    String sname=rs.getString(3);
    String itcode=rs.getString(4);
    String conunit=rs.getString(5);
    float qtyw = rs.getFloat(6);
    float oupw=rs.getFloat(7);
    float oepw=rs.getFloat(8);
    %>
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td bgcolor='#E6E4E4' align="Center" width=100%><font color="#5d7a80" size=2>BOQ OF MOPS </font> </td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr><td >
    1)SERIAL NUMBER:</td><td><input type=text name=serialno1 value= "<%=serialno%>" size=10 onblur = "caps();">
    </td></tr>
    <tr><td >
    2)SITE NUMBER:</td><td><input type=text name=sitenumber value= "<%=stcode%>" size=10 onblur = "caps();">
    </td></tr>
    <tr><td >
    3)SITE NAME:</td><td><input type=text name=sitename value= "<%=sname%>" size=10 onblur = "caps();">
    </td></tr>
    <tr><td>
    4)ITEM CODE/MATERIAL CODE:</td><td><input type=text name=itemno value= "<%=itcode%>" size = 20 onblur = "caps();" >
    </td></tr>
    <tr><td>
    5)CONTRACT UNIT DESCRIPTION:</td><td><input type=text name=contract value= "<%=conunit%>" size = 20 onblur = "caps();" >
    </td></tr>
    <tr><td>
    6)QUANTITY:</td><td><input type="text" name="quantity" value= "<%=qtyw%>" size =40 onblur = "caps();" >
    </td></tr>
    <tr><td>
    7)ORIGNAL UNIT/PRICE:</td><td><input type=text name=orig value= "<%=oupw%>" size = 20 onblur = "caps();" >
    </td></tr>
    <tr><td>
    8)ORIGNAL EXTENDED/PRICE:</td><td><input type=text name=origexp value= "<%=oepw%>" size = 20 onblur = "caps();" >
    </td></tr>
    </TABLE>
    <%
    %>
    <center>
    <table>
    <tr><td>
    <INPUT TYPE=Submit value = Update name="btnUpdate" size=20/></td> </tr></table>
    </form>
    <form action="BOQVIEW.jsp" method = post>
    <center> <table>
    <tr><td>
    <input type="submit" value="View" size="20"></input>
    </td> </tr></table>
    </form>
    </form>
    </table>
    </center>
    <hr>
    <script type="text/javascript">
    Calendar.setup({
    inputField : "f_date_b", //*
    ifFormat : "%d-%b-%Y ",
    showsTime : false,
    button : "f_trigger_b", //*
    step : 1
    Calendar.setup({
    inputField : "f_date_b1", //*
    ifFormat : "%d-%b-%Y",
    showsTime : false,
    button : "f_trigger_b1", //*
    step : 1
    </script>
    </BODY>
    <%
    catch(Exception e)
    out.println(e.getMessage());
    finally
    try
    if(con!=null)
    con.close();
    catch(SQLException sq)
    out.println(sq.getMessage());
    %>
    </HTML>
    this my table database oracle 9i
    CREATE TABLE BOQ
    S_NO INTEGER NOT NULL,
    SITE_CODE INTEGER,
    SITE_NAME VARCHAR2(40),
    ITEM_CODE VARCHAR2(20),
    CONTRACT_UNIT VARCHAR2(60),
    QTY FLOAT(70),
    O_U_P FLOAT(70),
    O_E_P FLOAT(70)
    );</a>

    1. Use code tags, there's button that says 'Code'. Select your text and use that. I'm not going to read your code while it's unformatted like this and especially because you seem to have posted your whole darn project here; and I suspect few others will bother either.
    2. Don't paraphrase the exception; post the exact stack trace.
    3. There's usually a line number given with the exception; which line does your stack trace point to? Try to figure out what you're doing wrong there.
    4. NumberFormatException means that you're trying to parse a string that's not in the correct format. Make sure the data you're getting from the DB is correct.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • Update routine infinite loop

    Hello Experts,
    For loading ODS2 we are making a lookup on ODS1 for 0material based on
    purchaing document number, item line item.
    Is there any mistake in the start routine or update routine.
    Because the load goes in infinite loop. I think update routine should be changed.
    Any suggestions are appreciated
    Start routine:
    data: begin of itab occurs 0,
            pur_doc like /BIC/AZODS100-OI_EBELN,
            item like /BIC/AZODS100-OI_EBELP,
            material like /BIC/AZODS100-material,
          end of itab.
    clear itab.
    select OI_EBELN OI_EBELP MAT_PLANT from /BIC/AZODS100
             into table itab.
    Update routine for 0material
    loop at itab where pur_doc = COMM_STRUCTURE-OI_EBELN
                       and item = COMM_STRUCTURE-OI_EBELP.
           RESULT = itab-matplant.
    endloop.

    Hi,
    this takes a long time, because with each record of your data packaged it is doing the loop and scanning each row of the internal table. Use the following instead.
    Start routine:
    types: begin of t_itab,
    pur_doc like /BIC/AZODS100-OI_EBELN,
    item like /BIC/AZODS100-OI_EBELP,
    material like /BIC/AZODS100-material,
    end of t_itab.
    data: itab type hashed table of t_itab with unique key pur_doc item.
    select OI_EBELN OI_EBELP MAT_PLANT from /BIC/AZODS100
    into table itab order by oi_ebeln oi_ebelp mat_plant.
    I hope these fields are the key of the ods object.
    Update routine for 0material
    data: wa_itab type t_itab.
    read table itab into wa_itab with table key pur_doc = COMM_STRUCTURE-OI_EBELN
    item = COMM_STRUCTURE-OI_EBELP.
    if sy-subrc = 0.
    RESULT = wa_itab-matplant.
    else.
    clear result.
    endif.
    Hope this helps
    regards
    Siggi

  • How do I remove NaN values from an array?

    I'm trying to test if the values in an array are less than 0.001. All of them are...BUT the problem is that some of the elements in the array are NaN. I'd like to do one of two things:
    1. Remove the NaN elements from the array and set them to zero to make the test work.
    2. Make the test understand that NaN elements are okay.
    The test results in a boolean array of T/F values. If all of the values of the boolean array are T, it will result in a single boolean value of T. In #2, I am saying that I want it to test if an element of the array is less than 0.001 OR equal to NAN.
    Solved!
    Go to Solution.

    Your statements don't make much sense. It's irrelevant how many NaNs are in the array. A sort will move them all to the bottom. You had said you wanted to find out if all the elements in an array are less than 0.001, and that you've got some NaNs in there. Well, this will do that:
    twolfe13 wrote:
     I did see how to remove NaN once, but couldn't determine a good way to generalize it other than doing a test loop. I thought there might have been a simple function that I overlooked to do this.
    As I noted, there have been several posts in the past about efficient techniques for removing certain elements out of an array. Seek, and ye shall find.
    Joseph Loo wrote:
    Have you look at the coerce function where you can set the lower and upper limit?
    That won't do anything for NaN. Or perhaps I misunderstood what you are suggesting to do?
    Attachments:
    NaN sort.png ‏20 KB
    NaN sort small.png ‏5 KB

  • New system, random shutdowns w/ infinite reboot-cycle afterwards

    The problem:
    When using the machine normally, it will shutdown/go out. 2-3 seconds later, the machine turns on by itself, stays on for 1-2 seconds, Shutts off. Comes back after 2-3 seconds and shuts off again after 1-2 seconds of been on. It looks like it would continue this cycle infinitly, if I didn't physically turn off the power supply to the system. (I let it repeat 7-8 times, before I decided to cut off the power entirely from the system.)
    After cutting off the power entirely, I'm able to boot it up normally next time I plug it back in. The problem repeats itself, when it decides to shutdown randomly while in WindowsXP.
    This is my first MSI board. I chosed it because reviews showed it, that at stock speeds, it was the fastest in gaming benchmarks. I guess, I should've checked for stability issues first on the web :( The system:
    MSI 875P Neo Motherboard
    Intel P4 3.2G 800 Processor
    1GB Mushkin PC3200 Level 1 CAS2 DDR SDRAM, 2ea. DIMMs, w/heat spreaders
    Radeon 9800 Pro 256MB 4.1 catalyst driver
    Audigy 2
    Adaptec 29160N Ultra160 SCSI Host Adapter
    Plextor Ultraplex 40MAX SCSI CD-ROM
    Seagate ST336753LW 15k 68-pin U320 SCSI Hard Drive
    Mitsumi 1.44MB Floppy Driver
    Antec Performance One P160 Aluminum Chassis
    Antec SL350 350W Dual-Fan Power Supply
    Mad Hatter

    Quote
    Originally posted by Danny
    It's not my calculator. I like it, think it's fairly accurate and certainly useful. But I can take no credit for it. The author does browse this forum and hopefully will speak up if he wants the well deserved credit.
    I like it too.  All credit to the creator.  not meaning to slight anyone.   I also appreciate your link to it.
    Sure is useful, as I am sure most people, including myself, don't realize how much wattage they are consuming.
    These threads have surely convinced me of the value of a quality PSU.
    Was hanging out at CompUsa a month ago talking to a nice, bidget-minded feller who wanted all the cool light mods, and a cheap, but cool case, with no inkling of the power needs. Being the disciple I am now, I wish I could talk to him today and proselytize about power...

  • How to out from infinite while loop in sub VI

    Dear Sir,
    how to out from infinite while loop in sub VI from main VI
    attached photo for solution but I can't understand it and i can't find the function in photo 
    please help
    Attachments:
    stop_subVI_frm_main.JPG ‏36 KB

    Asking how to get out of an infinite loop is like asking how to find the end of a circle. I'm not trying to be sarcastic but by definition, if there is a way out of the loop, then it is not infinite. I think what you are asking is how to avoid creating an infinite loop. Is there something about the suggestions you have been given that you do not like? My favorite suggestion is the notifier but maybe you just need an example. Turn on context help and read about the notifier functions in the code below.
    This is your top level VI
    And this is your subVI
    If this seems too complex then a global variable will work too. But what seems simpler can cause much more complex bugs. You can code fast and spend lots of time debugging or you can code slow and spend less time debugging. Personally I perfer writing productive code than looking for bugs any time.
    =====================
    LabVIEW 2012

Maybe you are looking for

  • Adobe Reader XI keeps crashing

    I have tried uninstalling and reinstalling but the same thing happens; open a pdf doc it appears but then a dialog box comes up 'This program has stopped working' only option is to close the program. Is anyone else experiencing this problem? Any clue

  • 16:9 editing (black bars)

    I have a Final Cut project which I have assembled from .mov video clips. The clips are 16:9 (640x360), but when I render them they show up in the canvas with black bars above and below, even though I have the sequence settings set to 640x360. When I

  • Folder Sync

    Hi, Is there a way to get iTunes to check folders for new music and automatically add that music to its library (without copying, moving or reorganizing the files)? Example - I have a folder that I download new music to. I want iTunes to see this mus

  • Confirmations after SRM Server update to level 9

    We are having an issue with regards to Confirmation of goods, we have a po of 300 units and we have confirmed 85 but this has failed there is no figures in the confirmed Qty nor is there a value. Any ideas?

  • Cannot get Aperture External Editor to work with CS2

    Hi, I've been trying to get Aperture to work with CS2 as the External Editor. After setting the Aperture prefs and trying it out, CS2 opens, but goes into an eternal wait state without the picture ever showing up. After this happens, CS2 no longer wo