How to get the length of a field value, not the length of DB's CHAR(20)

Hello.
I'm trying to handle a String from my DataBase and get its length:
String myName;
int i;
PreparedStatement sql = Conn.prepareStatement("SELECT NAME FROM MY_TABLE");
ResultSet results = sql.executeQuery();
results.next();
myName = results.getString("NAME");
i = myName.length();
out.println("The value is " + myName + " and the length is " + String.valueOf(i) );
I get:
" The value is Tom and the lengh is 20 "
20 is the length of the field (it's a CHAR (20) ), but I would like to get the length
of 'Tom'.
On other hand, I would like to detect if this value is 'Tom' or not, but trying with:
if (myName.equals("Tom")) {...}
or
if (myName == "Tom") {...}
There is no response.
Any experience?

myName = results.getString("NAME");
if(myName!=null) myName = myName.trim(); //Take out trailing spaces
i = myName.length();Sudha

Similar Messages

  • How to get data from COSP table, field HRKFT as the key to data from PM?

    Dear ladies and gentlemen!
    I need to get data from COSP table, field HRKFT as the key to data from PM tables (AFKO and AUFK).
    The problem is that it is a key field to the COSP, and all non-key fields as an alternative to HRKFT are not suitable for this task.
    All this is necessary for the extractor, which loads the data from the R \ 3 systems in the BW-system. I need to perform SELECT from a table COSP and maybe also JOIN, most likely between tables COSP and AUFK.
    What should I do in this case?
    Thank you very much in advance!

    From information on help.sap.com I've made a conclusion that one of possible solutions in theory is to modify standard extractor PM_OM_OPA_1 in order to make HRKFT field available for work, because by default it is hidden by SAP and not available for use as a key field.
    Of course, it's not a very good solution, but for now I know no other way to solve this problem.
    Maybe someone knows better ways? In this case I will be very grateful for any help!
    Moderator: You'd better post it on BI forums

  • How to get a specific page's field values in pdf ?

    I am using acrobat javascript to read a pdf file. Is there any way to read textfield values which are present in a specific page?

    Yes.
    Have you download the Acrobat SDK and read the JavaScript documentation?

  • How can I get the previous record's field value in a VO

    Hi I would like to know how can I get the previous record's field value in a VO
    For example : I have a VO porequisitionlinesvoimpl, and it contains 5 records (porequisitionlinesvoimpl.getRowCount() = 5). How can I search all records in the VO and get the field (attribute3) for all records?
    Many thanks anyone can help
    Lawrence

    Hi ,
    U can loop through the VO to get the value of attribute3,
    need to extend the controller ,use below code
    OAViewObject vo = (OAViewObject)oawebbean.getApplicationModule (VO1);
    OARow row = null;
    int fetchedRowCount = vo.getFetchedRowCount();
    RowSetIterator Iter = vo.createRowSetIterator("Iter");
    if (fetchedRowCount > 0)
    Iter .setRangeStart(0);
    Iter .setRangeSize(fetchedRowCount);
    for (int i = 0; i < fetchedRowCount; i++)
    row = (OARow)Iter .getRowAtRangeIndex(i);
    String value = (String)row.getAttribute("Atrribute3");
    Thanks
    Pratap

  • How to get a field value in the report

    hi all :-
    i need to get the field value in the formate trigger inside a specified field in the report?

    please post your request in the report category forum

  • How to get automatically sysdate in a field

    How to get sysdate automatically in a field in ADF

    As provided in the above blog post provided by Branislav,
    use the groovy expressions for defaulting the date using the following expressions is the right & recommended approach:
    Only date: adf.currentDate
    Date with Time: adf.currentDateTime
    see section 3.6.1 in ADF Developer's guide:
    http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcintro.htm#CEGJJJBA
    Thanks,
    Navaneeth

  • How to get google back in search field

    how to get google back in search field of Safari

    Safari 6
    URL address bar and Google search are unified and is called Smart search field.
    When you search with Google "Google search" will appear.
    There is no more a separate Google search field.
    Prior versions of Safari
    Click the "View" menu in the Safari menu bar and select "Customize Toolbar".
    From the dropdown drag the default set into the Toolbar.

  • How to add field value to the standard table

    Hi,
    How to add field value to the standard table?
    for example:
    when we go to TCODE SE16-> VBAK table -> on the selection screen if we press F4 against VBTYP we get all the available values for that field. How to add a new document Category value to this field so that it shows up in F4 help for that field.

    Hi Asif,
    I don't think it is possible and feasible for adding new field value to the field VBTYP because it is not possible through SPRO.
    If u see the domain of this field VBTYP we have fixed values provided by SAP. There is no value table for this. If u have value table then it will be updated through SPRO. But still if u really want to add some value u can do that by getting access key and add the value in the fixed values of the domain. But of no use other than simply displaying in F4. Because for what ever value u created here there will be no documents in VBAK or any table using this domain.
    Hope this is clear for u.
    Thanks,
    Vinod.

  • How can I add form field value to the file name in save as dialog box

    I do not want the form to be saved automatically, just want the form to auto populate the "file name" only.
    A little background on the forms I want to use:  My company has 70 retail outlets, I'll use one of our pdf forms called an "Incident Report" as an example.  I would like for a store manager to be able to complete the form, then email the form to the main office (I already have javascript to add field values and form name to the email subject line), once the main office receives it, I want for them to be able to file the pdf electronically on our server.  We have mutliple forms that we use so I do not want any of the forms to automatically save anywhere, (at this time anyway) I just want the office personnel to be able to click "save as" (or whatever they will need to click) and the form automatically add certain field values from the pdf they have received, of which will be different each time the form is sent to the office (Date, store #, employee name etc.) in addition to the name of the form in the "File name" of the "Save As" dialog box.  The main office employees will decide into which server file the pdf should be saved.
    I'm using Acrobat 8 professional, the stores and office personnel use Adobe reader.
    One little note:  We currently print and file a lot of paper on a daily bases, as soon as I can get this to work, we are going green.
    Me and a lot of trees in this will really apprecitate any help you can give with this!  :-)

    You might want to take a look at the document "Developing Acrobat Applications Using JavaScript" (js_developer_guide.pdf) which is part of the Adobe Acrobat SDK, which can be downloaded here. Read the "Privileged versus non-privileged context" (p. 45ff.). You will find an example for "Executing privileged methods in a non-privileged context". Should be almost exactly what you are looking for.
    Small Outline: For security reasons ("the user always has to know what's going on") you are not allowed to use the "Doc.saveAs"-method without the user permission (--> in a non-privileged context). In order to reach the goal of a privileged context you can use a trusted function. You do this by creating a JavaScript file (*.js) in either the Application-JavaScript-Folder (default location on Windows systems: "%ProgramFiles%\Adobe\Acrobat 10.0\Acrobat\Javascripts") or the User-JavaScript-Folder (default location on Windows systems: "%AppData%\Adobe\Acrobat\10.0\JavaScripts"). Add the following content to the new file:
    myTrustedBrowseForDoc = app.trustedFunction( function ( oArgs ) {
         app.beginPriv();
              var myTrustedRetn = app.browseForDoc( oArgs );
         app.endPriv();
         return myTrustedRetn;
    myTrustedSaveAs = app.trustedFunction( function ( doc, oArgs ) {
         app.beginPriv();
              var myTrustedRetn = doc.saveAs( oArgs );
         app.endPriv();
         return myTrustedRetn;
    The developer guide actually wants you to add this content to the existing "config.js" file. I recommend creating a new file, since its easier to deploy in a network. Either way, every client/user who needs to be able to save documents this way, needs this JavaScript Code in his Application/User-JavaScript-Folder.
    Within the Acrobat Document, which you want to obtain a certain file name, you can now use the trusted functions "myTrustedBrowseForDoc" and "myTrustedSaveAs" to store the file. To call the trusted functions and deliver the file name you can either you use a form field (button) or you add a new menu item. Add the following JavaScript Action to the button/menu item and change "Roller Coaster" to the name of the field which contains the value which you want to become the new file name:
    var fileName = this.getField("Roller Coaster").valueAsString;
    try {
         var oRetn = myTrustedBrowseForDoc({bSave: true, cFilenameInit: fileName + ".pdf"});
         try {
              myTrustedSaveAs(this, { cPath: oRetn.cPath, cFS:oRetn.cFS });
         catch(e) {
              console.println("Save not allowed, perhaps readonly.");
    catch(e) {
    console.println("User cancelled Save As dialog box");
    Good Luck!

  • How do I get my deleted emails to go to the deleted items in Outlook and not the archived folder?

    How do I get my deleted emails to go to the deleted items in Outlook and not the archived folder?

    Who is the email account provider?
    With an Apple iCloud account, there is a preference setting with the account settings on the iPhone to archive messages - save deleted messages in your Archive folder.
    I believe the same is available with a Gmail account.

  • How can we read the screen field values from the report selection screen wi

    Hi expart,
    How can we read the screen field values from the report selection screen with out having an ENTER button pressed  .
    Regards
    Razz

    use this code...
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_posnr.
    **Read the Values of the SCREEN FIELDs
    CALL FUNCTION 'DYNP_VALUES_READ'

  • How to get column names for a specific view in the scheme?

    how to get column names for a specific view in the scheme?
    TIA
    Don't have DD on the wall anymore....

    or this?
    SQL> select text from ALL_VIEWS
      2  where VIEW_NAME
      3  ='EMP_VIEW';
    TEXT
    SELECT empno,ename FROM EMP
    WHERE empno=10

  • How can i transfer a field value in the main report to its sub-report?

    <p><font face="Arial" size="2">How can i transfer a field value in the main report to its sub-report?</font></p><p><font face="Arial" size="2">Please eloberate with example if possible!</font></p><p><font face="Arial" size="2">Thanks...</font></p><p> </p>

    <p>You can do a couple of things - one would be to pass the information using the data linking expert.  Right click on the subreport, choose &#39;Change Subreport Links&#39; and select the field(s) you are wanting to pass to the subreport.  CRW will build parameters and a record selection formula for you in the subreport, and if that&#39;s what you want, then great.  But you can also remove the selection formula from the subreport and work with the parameter fields in the subreport however you would like.</p><p>Alternatively, you can look to passing Shared variables back and forth from the main and subreport.  this link talks about the method to do this: http://diamond.businessobjects.com/node/251</p><p> </p>

  • I just got the iphone 4s and i cant figure out how to get siri to work it seems to be the old voice command. HELP!

    i just got the iphone 4s and i cant figure out how to get siri to work it seems to be the old voice command. HELP!

    Did you enable Siri in settings?
    Settings > General > Siri > ON
    If Siri is off, all you get when pressing the home button for 1 second is the old Voice Control.

  • How to get last Build date of a dll in the real time target

    Info On My Project    
       I am working on LabWindows CVI 12.0 for development . This project is a real time application for hardware, which is having Phar Lap ETS as RTOS...  
    I am facing some problems while checking Build date of my Application file( .dll)
    I have tried to use GetFileDate API. But it is not supporting for realtime Target..
    So i have tried __DATE__ macro.. That also having some problems..
    How to get last Build date of a dll from the real time target  ??
    Please Help to solve this....
    Thanks
    Vaishakh A  K

    Please reply if any one have suggestion...

Maybe you are looking for