Problem converting string to int

I want to display records of flights from my database with the things that i get from a form...One of them is the number of passengers...the code is shown below;
" SELECT * FROM flights WHERE kalkis LIKE ? AND inis LIKE ? AND DepartureDate LIKE ? AND NumPass >= ? ";
Everything comes up right except the NumPass value...i get the ? value by saying;
sorgulama.setInt(4,Integer.parseInt(request.getParameter("NumPass")));
But it won't display the values that are >=...Displays nothing...
Also the NumPass value is "int" type in the database...
Any idea to solve this...kinda urgent ..

Log the parameters being used in your application.
Run the query directly against the database using the parameters your app is using, verify you find something.

Similar Messages

  • Problem with String to Int conversion

    Dear Friends,
    Problem with String to Int conversion
    I am having a column where most of the values are numeric. Only 4 values are non numeric.
    I have replaces those non numeric values to numeric in order to maintain the data type.
    CASE Grade.Grade  WHEN 'E4' THEN '24'  WHEN 'E3' THEN '23'  WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade  END
    This comes the result as down
    Grade
    _0_
    _1_
    _10_
    _11_
    _12_
    _13_
    _14_
    _15_
    _16_
    _17_
    _18_
    _19_
    _2_
    _20_
    _21_
    _22_
    _23_
    _24_
    _3_
    _4_
    _5_
    _6_
    _7_
    _8_
    _9_
    Refresh
    Now I want to convert this value to numeric and do some calculation
    So I changed the formula as below
    cast (CASE Grade.Grade  WHEN 'E4' THEN '24'  WHEN 'E3' THEN '23'  WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade  END as INT)
    Now I get the following error
    View Display Error
    _     Odbc driver returned an error (SQLExecDirectW)._
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    _State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1722, message: ORA-01722: invalid number at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)_
    SQL Issued: SELECT cast ( CASE Grade.Grade WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade END as Int) saw0 FROM "Human Capital - Manpower Costing" WHERE LENGTH(CASE Grade.Grade WHEN 'E1' THEN '20' WHEN 'E2' THEN '21' WHEN 'E3' THEN '22' WHEN 'E4' THEN '23' ELSE Grade.Grade END) > 0 ORDER BY saw_0_
    Refresh
    Could anybody help me
    Regards
    Mustafa
    Edited by: Musnet on Jun 29, 2010 5:42 AM
    Edited by: Musnet on Jun 29, 2010 6:48 AM

    Dear Kart,
    This give me another hint, Yes you are right. There was one row which returns neither blank nor any value.
    I have done the code like following and it works fine
    Thanks again for your support
    Regards
    Code: cast (CASE (CASE WHEN Length(Grade.Grade)=0 THEN '--' ELSE Grade.Grade END) WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' when '--' then '-1' ELSE Grade.Grade END as Int)

  • Converting string to int

    I cannot convert this string to integer.
    int tempI = Integer.parseInt("fdcedfbd", 16);
    it returns a numberFormatException
    but if I do this then there will be no problem.
    int tempI = 0xfdcedfbd
    Can anybody help me with this? Thank you.

    It sounds like the real problem here is that someone is giving you an 8-byte unsigned value represented as a 16-character hexadecimal string, and they want you to convert that into the actual 8 bytes. Are they going to do bit manipulation on it or something?
    If you successfully convert it into a long and they then try to do math with it, they'll run into the sign/overflow problems everyone else has been talking about. If they just want to look at the individual bits then it would make sense to do the conversion into a long.
    You could do something like this:
      private static final String highOrderDigits = "89abcdef";
      public long hexToLong(String hex) {
        // Only process exactly 16-digit strings.
        if (hex.length() != 16) {
          throw new IllegalArgumentException("Expect 16-digit hex value");
        boolean overflow = false;
        // Check for most significant digit > 7, which would
        // cause problem for parseLong.
        int highOrderIndex = highOrderDigits.indexOf(hex.charAt(0));
        if (highOrderIndex > -1) {
          // Clear most-significant bit and set overflow flag.
          overflow = true;
          hex = "" + highOrderIndex + hex.substring(1);
        long result = Long.parseLong(hex, 16);
        if (overflow) {
          // Manually set most significant bit in result.
          result |= 0x8000000000000000L;
        return result;
      }I more or less tested this and it looks to work.

  • How to convert String to int in JSP?

    Hi,
    I set a session attribute in Servlet and want use it in JSP, How can I convert it to int or Integer?
    the line in my code doesn't work:
    int quantity=(int)session.getAttribute("vehiclequantity") ;
    Thanks in advance.
    Wolf
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    <HTML>
    <HEAD>
    <TITLE>Using the for Statement</TITLE>
    </HEAD>
    <BODY>
    <H1>Using the for Statement</H1>
    <%=session.getAttribute("vehiclequantity") %>;
    <%
    int loopIndex;
    int quantity=(int)session.getAttribute("vehiclequantity") ;
    out.println(quantity);
    for (loopIndex = 1; loopIndex <=2; loopIndex++) {
    out.println("This is iteration number "
    + loopIndex + "<BR>");
    %>
    </BODY>
    </HTML>

    Learning how to read errors and understand them will help you solve your problems quicker by yourself... So lets take a look at the error and classes involved...
    The error says:
    "Cannor Resolve Symbol: method valueOf(java.lang.Object) in the class java.lang.Integer" and gives you line line where the error occurs: Integer quantity = Integer.valueOf(session.getAttribute("vehiclequantity"));
    Now, if we look at the API for the Integer we notice that are are only two valueOf methods: valueOf(java.lang.String s) and valueOf(java.lang.String s, int radix). Not valueOf(java.lang.Object) method.
    Now we look at the getAttribute(java.lang.String name) method of HttpSession we see that the method returns a java.lang.Object. Now, you know you put a java.lang.String into that attribute, but the get method returns an Object. This is because you could have put any object in there, an Integer, a String, or some other class instance. But you know it is a String, so you can cast the returned value to a String, so that you will be calling the valueOf(java.lang.String s) method of Integer with the Object returned from the HtttpSession's getAttribute(java.lang.String name) method:
    Integer quantity = Integer.valueOf((String)session.getAttribute("vehiclequantity"));

  • Problem formatting string with ints

    I'm trying to perform simple string formatting using a resource file but I'm having problems when I pass integers to the format argument.
    Here is the line of code that causes the IllegalFormatConversionException:
    ResourceFile.getFormattedString("XMLGAME",myBounds.getWidth(),myBounds.getHeight())//myBounds.getWidth() and myBounds.getHeight() return intsHere is the method in ResourceFile:
    public static String getFormattedString(String resource, int... args)
        return String.format(resourceFile.getString(resource), args);
    }And here is the string in the properties file
    XMLGAME  <game name="game" width="%d" height="%d">\nEdited by: JFactor2004 on Dec 3, 2008 10:15 PM

    Instead of {color:000080}int{color}..., declare "args" the same way format() does, as Object...: public static String getFormattedString(String resource, Object... args) The way you're doing it would require the {color:000080}int{color}[] to be "bulk-autoboxed" to an Integer[] or Object[], and Java can't do that. Instead, it treats "args" as an Object[] containing one element, which happens to be an {color:000080}int{color}[].

  • Exception thrown trying to convert string to int

    Hey Guys,
    i imported a csv file into my app which i divide using the split() method and put into an array then I divided the array into variables;
    fruit = piece[0];
    price = piece[1];
    unit = piece[2];Now since price has to be a double i converted it into a double;
    price2 = Double.parseDouble(price);which worked grand
    but when i try to convert unit to an integer
    unit2 = Integer.parseInt(unit);i got error
    Exception in thread "main" java.lang.NumberFormatException: For input string: "3
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    so i tried removing white spaces as follows
    target = unit.replace(" ", "");which worked and displayed grand, then i tried converting to int again but the same exception was thrown, can anyone help me with this problem, thanks
    mark

    sorry for the messed up format previously.
    Like you said the unit.replaceAll(" ", ""); did not do the trick, when displayed as a string it looked like 3 was on its own but still did not convert to int. I assume line break or something existed in the csv file like you mentioned earlier as unit was the last word in the csv file.
    when i used unit.trim(); and tried to convert to integer it worked perfectly.
    thanks all for your help,
    Mark

  • Combo Box, Converting string to int

    The user is able to select the month, year etc for a TimerTask using a combo box.
    The problem I have is converting say, "January" to an integer 0 for use to set in a calendar for the date.
    The combo box is populated with every month but i cannot link it with the int variable "month" where 0= january, 1- feb etc for use in the TimerTask.
    In other words, when the user selects "January" in the combo box i want the integer value for the variable "month" to equal 0, for "Febuary", month to equal 1, "March", month equal 2 etc etc.
    Any help would be excellent!!

    if January is the first item in the box, February is the second, all the way to December:
    month = monthComboBox().getSelectedIndex();

  • Problems converting string value to database timestamp

    I have values coming from a flat file in the form YYYYMM. I need to convert this value to a database timestamp. The reason for this is, furhter down in the flow, I need to bump this value up against a database table column in the form of YYYYMMDD HH:MM:SS.
    The first thing I do is tack on a day to the value so I have a string value in the form of YYYYMMDD. Once this is done, I then try to pass the value to a data conversion transformation. A sample value looks like this:
    20140801
    When I try to conver the string to DT_DBTIMESTAMP, I get:
    "The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
    I don't get it. The string is length 50. What am I missing?

    Had to break apart the source.
    SUBSTRING([Paid Period],1,4) + "-" + SUBSTRING([Paid Period],5,2) + "-01 " + "00:00:00.000"

  • Help trying to convert string to int

    Hey im trying to input a string in an applet then turn it into a integer so i can use it any ideas?

    long val = Long.parseLong(string);
    if(val > Integer.MAX_VALUE || val <
    Integer.MIN_VALUE) {
    throw new Error("I don't like you :p");
    int intVal = (int) val;No real need to use parseLong and check explicitly the limits. The check for MIN and MAX is performed implicitely inside Integer.parseInt(string, 10), which is called by both new Integer(string).intValue() and Integer.parseInt(string) . When the check fails, it throws a NumberFormatException.
    The only difference between post#1 and post#2 is that the latter it stores the int value in the internal int data member after the call to Integer.parseInt(string, 10), hence the intValue() subsequent call.

  • Converting string number int o percentage

    Hi. I have a textfield in which it accepts numbers (2.5 or 2.35 or 32.52)
    How am I going to convert it to double and in percentage format( .0025 or .0035 or .003252)
    Thanks
    Please help

    > and just converting it back to string again. I made
    the division but converting it back to string.
    what function do i need to use?
    In Java they're called "methods".
    http://java.sun.com/developer/JDCTechTips/2004/tt1005.html#2
    http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html
    ~

  • Converting String to int again...

    telno.addActionListener(this);
    public void actionPerformed(ActionEvent e){
    int x, p, y;
    if(e.getSource()==telno){
    x = Integer.parceInt(telno.getText());
         p = x/10000;
              y = x%10000;
    there's an error 'cannot resolve symbol' when I try to compile.
    Help please, anyone!
    Thanks

    Hi,
    parseInt() and not parceInt() I think.
    Hope it helps
    S�bastien

  • Converting String type to inte type

    Can any one tell me how I can convert an array of Strings into an array of integers??

    it's simple ..... it's like this...
       // some code goes here....
       String num[]={"23", "342", "21", "1"};
        int n[]= new int[num.length];
        for(int i=0; i<num.length; i++)
             n=Integer.parseInt(num[i]); // << -- convert string to int then copied it to int[]
    // rest of your code....

  • Javascript, string to int

    Dear Sir:
    I try to convert string to int in flash javascript:
    temp="120";
    temp2="140";
    temp3=int ( temp );
    but I got a message "int is not a function", can somebody tell me how to do this?
    also, what if I want convert number back to string?
    thanks a lot!

    use:
    temp="120";
    temp2="140";
    temp3=Number ( temp );
    // to convert to a string, use:
    var temp4:String=String(temp3);
    // or
    var temp5:String=temp3.toString();

  • Problem converting to INT from an XML file

    Hi folks, I hope you can help with this one, as it's been driving me nuts...
    Basically (and I'll try to keep this brief!) my project takes in an extremely basic XML file. I've never really done this before, but I seem to have got most of it working apart from taking in attribute values which I want to use as integers.
    Essentially, each element relates to objects of a basic class I have set up, while each attribute relates to the variables for the object. When the XML file is read, a new object is set up for each element and is stored in a linked list. That was supposed to be the difficult bit, but it turns out it hasn't been...
    The XML file looks a little bit like this (only the elements are shown to save space):
    <Object name="My object" description = "blah" x_axis = "96" y_axis="23" />
    <Object name="Another one" description = "blah, again" x_axis = "83" y_axis="40"/>
    etc. etc. The problem relates to the x_axis and y_axis attributes. While the description and name attributes are assigned correctly, for some reason the x_axis and y_axis attributes are both given values of zero when I convert them from Strings to Ints. After much printing to the console, kicking and screaming, I think I've narrowed the problem down to the following code:
    if (attrib.getName() == "x_axis")
    int myX = Integer.parseInt(attrib.getValue()); // converting a string to an int
    myObject.setSoundX_Axis(myX);
    // And, of course, I do the same sort of thing for the Y axis.Anyone know why I'm getting zero values? Is it something to do with the way I'm converting the string to an int in Java?
    Cheers for any help.

    int myX = Integer.parseInt(attrib.getValue());I don't see anything wrong. Try printing out the value of attrib.getValue() to see if it is what you expect. You may want to try:
    String s = "" + myX;
    if ( s.compareTo(attrib.getValue() != 0 ) {
        System.out.println("Don't compare: myX=" + myX + " getValue=" + attrib.getValue());
    }

  • Leading Zeroes are lost when convert from string to int

    What I'm trying to do is simple yet the solution has seemed difficult to find.
    I have a system that requires 4 digit numbers as "requisitionNo". The system uses JSPs and accepts the 4 digit number that the user inputs (fyi - duplicate handling is already managed). The input number (rNumber) is of STRING type and in the action (using struts) is converted to an int:
    int requisitionNo = Integer.parseInt(rNumber);At that very line the issue is that when the user inputs a number with leading zeros such as: "0001" the 3 leading zeros are chopped off in the INT conversion. The application validation kicks in and says: "A 4 digit number is required" which is by design. The work around has been that the user has been putting in number that start with 9's or something like that, but this isn't how the system was intended to be used.
    How do I keep the leading zeroes from being lost instead of saving a number "1" to the database how do I keep it saving "0001" to the database? Would I just change everything to STRING on down to the database? or is there another number type that I can be using that will not chop off the leading zeroes? Please provide short code references or examples to be more helpful.

    Yeah, I have to agree here that leading zeroes make no sense. I figured that out when I started to look into this problem. The only requirement that exists is that the user wants it to be a 4 digit number due to some other requirement they have themselves.
    So what I'm gathering from what I've read in the responses thus far is that I should change the validation a bit to look at the STRING for the 4 required digits (which are really 4 characters; maybe I should add CLIENT side numeric validation; currently its doing server side numeric/integer validation; or maybe change up the server side validation instead???) and if they are ALL GOOD then let the application save the int type as it wants to. IE: Let it save "0001" as just "1" and when I come back to DISPLAY this saved number to the user I should append the string of "000" in front of the 1 for display purposes only? Am I understanding everyone correctly?

Maybe you are looking for

  • *** Security Warning ***?!

      I just got this HTC thunderbolt from a friend and downloaded the software update from verizon to it. It rebooted and then I got *** LOCKED *** *** Security Warning *** MECHA XD SHIP S-ON HBOOT - 1.050000 MICROP-/ RADIO-1.49.00.0406w_1 eMMC-boot Jul

  • Multiple Unit of Measure (No Fix Conversion Formula)

    Dear All, Cilnet has given me requirement to book the sales document for the particualr product in unit of mesure 'Nos/PC', and the stock is maintained in Base Unit of Measure 'Qtl' (100 Kg = 1 Qtl). Price is also applicable or calculated on the basi

  • Is there any  example snippet for XPath using namespace

    Hi, I have used XpathApi class to get the XML node matching my xpath that does not deal with namespaces and it works for me. However, it does not seem to work well when I construct the xpath with namespaces (probably I may be doing something wrong ex

  • Reversal of statistical postings

    Hi all, it is possible to create a statistical postings with BUDAT (01.08.2014) in the future in a closed period (e.g only july 2014 is open). The problem is, I can't reverse it because the reversal has to be created with budat >= 01.08.2014, but aug

  • Update: No mail ?

    Installed OS Update 10-5-8. Window now: 'You cannot use this version of the application Mail.app with this version of Mac OS X' Cannot open to see which Mail version it is but believe its 3.5 Any help appreciated