(any body can answer this)

st.executeUpdate("select * from trainee where id = " + num );is not working. its taking num as string.....I tried alot...
HELP ME

st.executeUpdate("select * from trainee where id = " + num );Java 101: the "+" operator in the context where one operand is a String will always convert the other operand to a String, and concatenate the two Strings. In other words, yes, you've taken "num" and converted it to a String, an concatenated that onto the end of your select statement.
BUT your database doesn't execute Java objects, it executes the SQL you've sent it. So it will take the SQL you send it:
select * from trainee where id = [some numeric value written as a character string]and PARSE it; in so doing, it will convert that numberic value written as a character string back into a number. However, it will do so using it's rules, which may or may not be Java's rules. If the number is an integer, the conversion will usually work - the same number will be used in Java and inside the database; if the number is not an integer (or a tiny subset of the real numbers that happen to convert back and forth exactly), rounding will probably occur, and other conversion problems may also bite you.
The solution to all this (and many many other problems) is to use a PreparedStatement instead of a Statement.
PreparedStatement pstmt = conn.prepareStatement("select * from trainee where id = ?" );
// use the right data type - long, int, whatever
pstmt.setLong(1,num);
// don't use executeUpdate when you're not doing an update
pstmt.executeQuery();

Similar Messages

  • I need Expert Decomposition of classes in Source Code for my reaserch purpose. Any body can help me in this regard?

    <blockquote>Locked by Moderator as a duplicate/re-post.
    Please continue the discussion in this thread: [tiki-view_forum_thread.php?comments_parentId=698286&forumId=1]
    Thanks - c</blockquote>
    == Issue
    ==
    I have another kind of problem with Firefox
    == Description
    ==
    I need Expert Decomposition of classes in Source Code of Firefox for my research purpose. Any body can help me in this regard?
    == This happened
    ==
    Not sure how often
    == Firefox version
    ==
    3.0.19
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19
    == Plugins installed
    ==
    *-Default Plug-in
    *RealPlayer(tm) LiveConnect-Enabled Plug-In
    *6.0.12.1662
    *Office Plugin for Netscape Navigator
    *Google Update
    *Shockwave Flash 10.1 r53
    *Yahoo Application State Plugin version 1.0.0.7
    *Next Generation Java Plug-in 1.6.0_18 for Mozilla browsers
    *Adobe PDF Plug-In For Firefox and Netscape
    *DRM Netscape Network Object
    *Npdsplay dll
    *DRM Store Netscape Plugin

    Please let me tell you that I Expert Decomposition may be of any Version of Firefox or Thunder Bird.

  • Can any body please read this and ans me

    hi all,
    can any body please read this and tell is there any function module or some other thing is available.
    Material masters are location specific, and Progistix maintains part details in Canadian $, now we need to get the logic how SAP converts the standard cost of the material from Canadian $ to US $
       The plant number of Canada is 3002.

    Hi
    you would have to use the following function modules
    CONVERT_TO_LOCAL_CURRENCY
    CONVERT_TO_FOREIGN_CURRENCY
    regards
    Dinesh

  • Hi , any body can send real time problems they faced

    hi every body this is siva from banglore, any body can send the real time problems they faced in sap crm and how they solved if any body kindly send to my id : [email protected]

    hi Siva,
    All the issues in the forums are the real time issues
    YOu can just go through them .
    Also why do you need real time issues.
    If you have any issues post it here and some one can help you

  • Hi.. i've got problem with my iPhone 4s gsm factory unlocked it won't connect to a wifi. i tried to hold power and home button even reset the network setting but ended with i am not able even to turn the wifi on. does any body can help me out???

    hi..
    i've got problem with my iphone 4s gsm factory unlocked it won't connect to a wifi. i tried to hold the power and home button even reset the network setting but ended with i am not even can turn the wifi on. does any body can helpme?

    See this: http://support.apple.com/kb/TS1559
    If you carefully follow all of the instructions in this tip and none of them restore WiFi then your radio chip has failed and you need to get the phone replaced by Apple.

  • After updating to 8.3 so many apps dont work properly. Any body else got this?

    After updating to 8.3 so many apps dont work properly. Any body else got this?

    This is truthfully a WAG but here are some standard repair procedures:
    First, try a system reset.  It cures many ills and it's quick, easy and harmless...
    Hold down the on/off switch and the Home button simultaneously until you see the Apple logo.  Ignore the "Slide to power off" text if it appears.  You will not lose any apps, data, music, movies, settings, etc.
    If the Reset doesn't work, try a Restore.  Note that it's nowhere near as quick as a Reset.  It could take well over an hour!  Connect via cable to the computer that you use for sync.  From iTunes, select the iPad/iPod and then select the Summary tab.  Follow the on-screen directions for Restore and be sure to say "yes" to the backup.  You will be warned that all data (apps, music, movies, etc.) will be erased but, as the Restore finishes, you will be asked if you wish the contents of the backup to be copied to the iPad/iPod.  Again, say "yes."
    At the end of the basic Restore, you will be asked if you wish to sync the iPad/iPod.  As before, say "yes."  Note that that sync selection will disappear and the Restore will end if you do not respond within a reasonable time.  If that happens, only the apps that are part of the IOS will appear on your device.  Corrective action is simple -  choose manual "Sync" from the bottom right of iTunes.
    If you're unable to do the Restore (or it doesn't help), go into Recovery Mode per the instructions here.  You WILL lose all of your data (game scores, etc,) but, for the most part, you can redownload apps and music without being charged again.  Also, read this.

  • Plesae any body can tell me some important real time FAQ's

    please any body can tell me some real time qutions they faced in interviews
    please it will help me a lot

    Hi,
    these are a few important questions
    ABAP Technical Interview Questions:
    1. What is the typical structure of an ABAP program?
    2. What are field symbols and field groups.? Have you used "component idx of structure" clause with field groups?
    3. What should be the approach for writing a BDC program?
    4. What is a batch input session?
    5. What is the alternative to batch input session?
    6. A situation: An ABAP program creates a batch input session. We need to submit the program and the batch session in background. How to do it?
    7. What is the difference between a pool table and a transparent table and how they are stored at the database level?
    8. What are the problems in processing batch input sessions? How is batch input process different from processing on line?
    9. What do you define in the domain and data element?
    10. What are the different types of data dictionary objects?
    11. How many types of tables exist and what are they in data dictionary?
    12. What is the step-by-step process to create a table in data dictionary?
    13. Can a transparent table exist in data dictionary but not in the database physically?
    14. What are the domains and data elements?
    15. Can you create a table with fields not referring to data elements?
    16. What is the advantage of structures? How do you use them in the ABAP programs?
    17. What does an extract statement do in the ABAP program?
    18. What is a collect statement? How is it different from append?
    19. What is open sql vs native sql?
    20. What does an EXEC SQL stmt do in ABAP? What is the disadvantage of using it?
    21. What is the meaning of ABAP editor integrated with ABAP data dictionary?
    22. What are the events in ABAP language?
    23. What is an interactive report? What is the obvious diff of such report compared with classical type reports?
    24. What is a drill down report?
    25. How do you write a function module in SAP? Describe.
    26. What are the exceptions in function module?
    27. What is a function group?
    28. How are the date abd time field values stored in SAP?
    29. What are the fields in a BDC_Tab Table?
    30. Name a few data dictionary objects?
    31. What happens when a table is activated in DD?
    32. What is a check table and what is a value table?
    33. What are match codes? Describe?
    34. What transactions do you use for data analysis?
    35. What is table maintenance generator?
    36. What are ranges? What are number ranges?
    37. What are select options and what is the diff from parameters?
    38. How do you validate the selection criteria of a report? And how do you display initial values in a selection screen?
    39. What are selection texts?
    40. What is CTS and what do you know about it?
    41. When a program is created and need to be transported to prodn does selection texts always go with it? if not how do you make sure? Can you change the CTS entries? How do you do it?
    42. What is the client concept in SAP? What is the meaning of client independent?
    43. Are programs client dependent?
    44. Name a few system global variables you can use in ABAP programs?
    45. What are internal tables? How do you get the number of lines in an internal table? How to use a specific number occurs statement?
    46. How do you take care of performance issues in your ABAP programs?
    47. What are datasets?
    48. How to find the return code of a stmt in ABAP programs?
    49. What are interface/conversion programs in SAP?
    50. Have you used SAP supplied programs to load master data?
    2. Adapted from response by Maram Roja on Tuesday, June 15, 2004
    1. What are the techniques involved in using SAP supplied programs? Do you prefer to write your own programs to load master data? Why?
    2. What are logical databases? What are the advantages/disadvantages of logical databases?
    3. What specific statements do you using when writing a drill down report?
    4. What are different tools to report data in SAP? What all have you used?
    5. What are the advantages and disadvantages of ABAP query tool?
    6. What are the functional areas? User groups? How does ABAP query work in relation to these?
    7. Is a logical database a requirement/must to write an ABAP query?
    8. What is the structure of a BDC sessions.
    9. What are Change header/detail tables? Have you used them?
    10. What do you do when the system crashes in the middle of a BDC batch session?
    11. What do you do with errors in BDC batch sessions?
    12. How do you set up background jobs in SAP? What are the steps? What are the event driven batch jobs?
    13. Is it possible to run host command from SAP environment? How do you run?
    14. What kind of financial periods exist in SAP? What is the relevant table for that?
    15. Does SAP handle multiple currencies? Multiple languages?
    16. What is a currency factoring technique?
    17. How do you document ABAP programs? Do you use program documentation menu option?
    18. What is SAPscript and layout set?
    19. What are the ABAP commands that link to a layout set?
    20. What is output determination?
    reward if helpful
    vivekanand

  • My iphone 5 is problem facing like that. when i switch off my iphone5 then plugh for charge with data cable or charger adapder or only data cable with no power connect phone is starting why? means on my phone Why? any one can explane this matter please. s

    my iphone 5 is problem facing like that. when i switch off my iphone5 then plugh for charge with data cable or charger adapder or only data cable with no power connect phone is starting why? means on my phone Why? any one can explane this matter please. switched off my phone but on without power button . what is the problem?
    Thanks
    s.m slim

    all iphone is same like that

  • Plz any one can forward this book to me!

    Hello Oracle Masters,
    Plz any one can forward this book to me! my mail id- [email protected]
    " Mastering Oracle PL/SQL: Practical Solutions By CONNOR MCDONALD, WITH CHAIM KATZ, CHRISTOPHER BECK, JOEL R. KALLMAN, AND DAVID C. KNOX"

    user600520 wrote:
    Hello Oracle Masters,I hate titles and salutations like these being thrown around. There are no "+masters+" here.. or "+gurus+".. or any form of so-called superior beings. That is simply a bunch of baloney on the part of those who claim these titles, and kind of pathetic of those who use these titles to curry favour.
    Plz any one can forward this book to me! my mail id- [email protected]
    It is silly to share your e-mail address in a public forum. It only opens your mailbox to abuse and spam
    " Mastering Oracle PL/SQL: Practical Solutions By CONNOR MCDONALD, WITH CHAIM KATZ, CHRISTOPHER BECK, JOEL R. KALLMAN, AND DAVID C. KNOX"Books are usually copyrighted and cannot be electronically copied and shared as that would be illegal. And I'm sure that you do not want to commit a crime...
    There are however books that can be read (and downloaded) on the Internet for free. Try http://docstore.mik.ua/orelly/oracle/ - these contains such books, dealing with PL/SQL.

  • TS2634 I have a very weak wifi signal, any body can help?

    I have a verry week wifi signal, any body can help?

    I have a verry week wifi signal, any body can help?

  • Iam facing a problem with JBorderless button please any body can solve my

    Dear Sir,
    Iam working on swing. for that iam using visualcafe tool. But for me iam facing a problem with JBorderlessbutton. I want set an image on that button for the button is displaying but the image is not displaying when i run the output. Iam using JDK1.4. Please any body can solve my problem If possible please send me a piece of code ill be thankful to you. Please.
    regards,
    surya

    Please supply some more information about the problem, e.g. a piece of code showing how the problem occurs.

  • To anybody that can answer this my iMac has 4gb memory how much faster would it be if i installed 16gb???

    to anybody that can answer this my iMac has 4gb memory how much faster would it be if i installed 16gb???

    Use activity moinot to view your typical usage, using this article as a guide:
    Using Activity Monitor to read System Memory and determine how much RAM is being used
    How much Green is in the pie chart?
    How much green plus Blue is in the pie chart?
    How much PageOuts since last Restart?
    How much current PageOuts in bytes/sec (number in parentheses)?

  • This trigger giving mutation error? any body can tell why?

    Hi All,
    Could any body tell me where is the problem in my trigger.
    my tables are.
    1) EMP :- emp_id,emp_movement_status
    2) EMPLOYEES_DAILY_MOVEMENT :- emp_id,transaction_time,transaction_remarks.
    if i delete a entry from transactions_table, it has to take latest remarks from the maximum record after deletion of the record, then update EMP table accordingly.
    trigger is:-
    CREATE OR REPLACE TRIGGER change_employee_status AFTER INSERT OR UPDATE OR DELETE ON
    employees_daily_movement FOR EACH ROW
    DECLARE
    local_remarks VARCHAR2(50);
    BEGIN
    IF DELETING THEN
    SELECT transaction_remarks INTO local_remarks FROM employees_daily_movement WHERE
         transaction_id = (SELECT MAX(transaction_id) FROM employees_daily_movement WHERE
         emp_id = :old.emp_id );
    /* here im expecting to take the TRANSACTION_REMARKS column value from employees_daily_movement after deleting the record which i wanted */
    UPDATE emp SET emp_movement_status = local_remarks WHERE emp_id = :old.emp_id;
    END IF;
    END;
    Thanks in advance

    Hi Mr Rao,
    You can handle muttating erros with following
    1. Database version is oracle 9i and above, you can over come this problem for ever by using pragma autonomous_transaction.
    2. Another way is, if you database version earlier to 9i then you can re-pharase this trigger by writting statement level trigger instead row level.
    Cheers!!
    Mahesh Ragineni

  • Can any body explain me this query?   select 'alter index '||index_name||' monitoring usage' as index_monitor from user_indexes where index_name='EMP';

    Initially i've a put an index of emp table in monitoring state..
    later i've got this query
    select 'alter index '||index_name||' monitoring usage' as index_monitor from user_indexes where index_name='EMP';
    can any body explain me what is the meaning of this query...
    and how do that query in the strings of projection area works....
    i'm totally confused
    thank you in advance.

    This is referred to as SQL generating SQL.  It is most useful when you  need to generate SQL statements for all indexes or indexes for one user.  After generating the text you then would execute it in SQLPlus or the tool of your choice.  If you combine this with a spool statement, SPOOL MyGeneratedScript.SQL you can run it with @MyGeneratedScript in SQLPlus.  I combine this into a script which generates the file, calls the editor so you can look it over and then executes it.  Here is an example of moving indexes to a different tablespace.
    -- UTL_Move_Indexs_To_New_TableSpace_Script.SQL
    /* This script will grab all the tables out of the specified source tablespace
    ** and move them into the specified target tablespace.  Ensure the the target
    ** exists and has sufficient room.  You must be logged in as the table owner.
    ACCEPT v_source_tablespace_name PROMPT 'Enter source tablespace name: '
    ACCEPT v_target_tablespace_name PROMPT 'Enter target tablespace name: '
    SET HEADING OFF
    SET FEEDBACK OFF
    SET TERMOUT OFF
    SET ECHO OFF
    SPOOL _move_index.SQL
    SELECT    'ALTER INDEX '
           || ndx.owner
           || '.'
           || ndx.index_name
           || CHR (10)
           || 'REBUILD '
           || CHR (10)
           || 'TABLESPACE '
           || UPPER ('&v_target_tablespace_name')
           || ';'
             sql_statement
    FROM   dba_indexes ndx
    WHERE      ndx.tablespace_name = UPPER ('&v_source_tablespace_name')
           AND ndx.index_type <> 'LOB'
    ORDER BY ndx.owner,
             ndx.index_name;
    SPOOL OFF
    --Edit the move script
    EDIT _move_index
    --Reset parameters.
    SET TERMOUT ON
    PAUSE Hit Ctrl+C to ABORT, any key to CONTINUE,
    -- Run the move script
    SPOOL  Move_Indexs_To_New_TableSpace.LOG
    @_move_index
    SPOOL OFF
    --Reset parameters.
    SET TERMOUT on
    SET FEEDBACK on
    SET HEADING on
    Marcus Baocn

  • Hai sir any body please answer to the query to which i am posting (please)

    hi
    any body please to the query which iam posting. i could not what exactly happens i was thinking so much even then i could not get the answer.
    Q) When we use the fix on dense or sparse on which dimension performance is good? How can you justify that?
    (IN PDF it is written this way)
    When you use the FIX command only on a dense dimension, Analytic Services retrieves the
    Entire block that contains the required value or values for the member or members that you
    Specify. Thus, I/O is not affected, and the calculation performance time is improved.
    When you use the FIX command on a sparse dimension, Analytic Services retrieves the block
    for the specified sparse dimension member or members. Thus, I/O may be greatly reduced.
    I cannot justify (visualize the above answer can any body help me the way it is going to happen from disk to the memory in the point of the performance) please elaborate what exact process takes.

    Hi,
    In Essbase (aka Analytic Services) block storage option (BSO) databases, the data block is the basic unit of I/O. A block contains cells that represent the intersections of stored members from dense dimensions. Unique data blocks are created for the existence of sparse dimension combinations (based on data loads or calculations).
    In a calc script, a FIX on a dense member will require the calculator to perform I/O on ALL the existing data blocks in the database. This may be logically necessary in some cases but it is not efficient in terms of minimizing I/O. Worse yet, a series of dense FIX statements (not nested but one after the other) will cause multiple, full passes on all data blocks. Conversely, a FIX on a sparse member will only require I/O on the data blocks related to that sparse member via the index. This is where you get I/O efficiency.
    To illustrate this in a simplistic example, let's say you have 1 million data blocks. One of the dense dimensions is Period with twelve months rolling up to quarters and total year. One of the sparse dimensions is Scenario with ten distinct scenarios (Actual, Budget, Forecast, etc.) and a Label Only setting at the top of the dimension (i.e., on Scenario at Gen 1). Consider the I/O differences on each FIX example to follow...
    FIX(Jan)
    ... any calc action here must perform I/O on all 1 million blocks
    ENDFIX
    FIX(Feb)
    ... any calc action here must perform I/O on all 1 million blocks AGAIN if written in sequence like this after the Jan FIX above
    ENDFIX
    However...
    FIX(Budget)
    ... any calc action here must perform I/O on only 1/10th of the database or 100,000 of the blocks
    ENDFIX
    Now these examples oversimplify some things to make the basic point about which you have asked a question. I hope this helps. Please post any follow-up questions.
    Good luck, Darrell Barr

Maybe you are looking for