Instance String[String] problem

HI,
I am having problem using instance array variable in an activity, on the other hand I create instance varible of a component(bpm object) & used it in automatic activity & it works fine.
step 1:* in albpm 6.0 studio I define instance variable name = statesList , type = String[[String]|http://forums.oracle.com/forums/] using Variable ---->instance window
STEP: 2*
in automatic activity I tried to insert data into the instance variable as follows
statesList \["NY"] = "New York";
but I get the following error on above line
{color:#ff0000}A component failed while executing activity '/TestJSPProcess#Default-1.0/Interactive{color}{color:#ff0000}' (BP-method startTest) over instance '/TestJSPProcess#Default-1.0/1/0'.
Details:
The method 'CIL_startTestStartTestIN' from class 'Test2.TestJSPProcess.Default_1_0.Instance' could not be successfully executed.
Caused by: java.lang.NullPointerException
fuego.lang.ComponentExecutionException: The method 'CIL_startTestStartTestIN' from class 'Test2.TestJSPProcess.Default_1_0.Instance' could not be successfully executed.
at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:506)
at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:260)
at fuego.fengine.FEEngineExecutionContext.invokeMethodAsCil(FEEngineExecutionContext.java:215)
at fuego.server.execution.EngineExecutionContext.runCil(EngineExecutionContext.java:1175)
at fuego.server.execution.TaskExecution.invoke(TaskExecution.java:428)
at fuego.server.execution.InteractiveNormalCilExecution.invoke(InteractiveNormalCilExecution.java:430)
at fuego.server.execution.TaskExecution.executeCIL(TaskExecution.java:553)
at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:737)
at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:697)
at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:178)
at fuego.server.execution.microactivity.InteractiveMicroActivity.executeNormalCil(InteractiveMicroActivity.java:489)
at fuego.server.execution.microactivity.InteractiveMicroActivity.executeItem(InteractiveMicroActivity.java:442)
at fuego.server.execution.microactivity.InteractiveMicroActivity.execute(InteractiveMicroActivity.java:100)
at fuego.server.AbstractProcessBean$45.execute(AbstractProcessBean.java:2938)
at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:304)
at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:470)
at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:551)
at fuego.transaction.TransactionAction.start(TransactionAction.java:212)
at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:123)
at fuego.server.execution.EngineExecution.executeImmediate(EngineExecution.java:66)
at fuego.server.AbstractProcessBean.runTask(AbstractProcessBean.java:2942)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fuego.lang.JavaClass.invokeMethod(JavaClass.java:1410)
at fuego.lang.JavaObject.invoke(JavaObject.java:227)
at fuego.component.Message.process(Message.java:587)
at fuego.component.ExecutionThread.processMessage(ExecutionThread.java:772)
at fuego.component.ExecutionThread.processBatch(ExecutionThread.java:747)
at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:143)
at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:135)
at fuego.fengine.FEngineProcessBean.processBatch(FEngineProcessBean.java:248)
at fuego.component.ExecutionThread.work(ExecutionThread.java:831)
at fuego.component.ExecutionThread.run(ExecutionThread.java:409)
Caused by: java.lang.NullPointerException
at xobject.Fuego__AutoGen__Screenflows__.__TestJSP2.getData(__TestJSP2.xcdl:7)
at xobject.Fuego__AutoGen__Screenflows__.__TestJSP2.getData_Invocator(__TestJSP2.xcdl:7)
at xobject.Fuego__AutoGen__Screenflows__.__TestJSP2.Begin_Router(__TestJSP2.xcdl:6)
at xobject.Fuego__AutoGen__Screenflows__.__TestJSP2.Begin_Invocator(__TestJSP2.xcdl:11)
at Test2.TestJSPProcess.Default_1_0.Instance.CIL_startTestStartTestIN(Instance.xcdl:4)
at Test2.TestJSPProcess.Default_1_0.Instance.CIL_startTestStartTestIN(Instance.xcdl)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:499)
... 34 more
{color}
If I initialized it before using it in automatic activity as follows
statesList as String\[String]
statesList \["NY"] = "New York";
no error comes... but in this way all the assignment goes into local variable & the instance variable I cerated in step 1 is still empty , I checked it on subsequent activities.
-KASH
Edited by: user586236 on Dec 4, 2008 8:41 AM
Edited by: user586236 on Dec 4, 2008 8:42 AM
Edited by: user586236 on Dec 4, 2008 8:44 AM

I solved the problem by making the local array & insert data fetched from db into that local array then assign this array to the instance array as follows
//local array
statesList_local as String\[String];
workItem.state = "NY";
//params as String[];
//params\[0] = "STATES"; //local var defined as String\[]
for each row in executeQuery(DynamicSQL, sentence : "select hl7code,value from D1_STATE", implname : "newConfiguration")
     do      statesList_local[String(row\["hl7code"])] = String(row\["value"])
logMessage String(row\["hl7code"])+":"+ String(row\["value"]) using severity = INFO
end
//assign local array to the instance variable one
statesList = statesList_local;
Edited by: user586236 on Dec 4, 2008 9:00 AM

Similar Messages

  • Host String Problem

    Hi everyone, i searched the forum and found same problem with me but i did not work for me. The problem is i cannot connect my sql plus. i enter my username and password then it asks me gor host string but when i type it and enter "ok" it says "TNS Listener does not currentl know of service requested in connect descriptor. i looked at my tnsnames.ora file and is exactly like this.
    # tnsnames.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    EXTPROC_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    CSE348 =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Canavar)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = cse348)
    So what shoul i type to connect sql plus?

    Given the tnsnames.ora content, the following needs to be entered for sqlplus in order to have it use that connection string in the file:
    sqlplus scott/tiger@CSE348As you have not qualified the alias with a domain, it will default to "+.world+" as far as I recall. If the default domain in your local sqlnet.ora differs, than that default will be used to find alias CSE348 in the local tnanmes.ora file. So make sure that you do not mix default and explicit domain names. Rather specify a default domain in sqlnet.ora and use the same domain for defining full qualified domain name TNS aliases in tnsnames.ora.
    As for the error - the Listener receives a connection request for a service called cse348 - and no such service has registered with it. You can check the known services of the listener using the "+lsnrctl services+" command on the server.
    Often in this case, it is easier to request a specific database instance using its system identifier, or SID. In which case you can change your connection string for the alias to use a SID as follows:
    CSE348 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = Canavar)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SID = cse348)
      )This assumes that the SID is cse348. The default SID is for example orcl. SIDs like dev and prod are also often used.

  • Tokenize string problem

    Hello,
    I have a database whose primarey key is an ID field where the ID is made up letters and numbers such as:
    'CB-01'
    'CB-02'
    'CB-03'
    I want to select the max ID from the database, add +1 to it and then display that new ID in a text box. The following query is giving me errors and I assume it's because you cannot add a number to ID which is a String:
         String sql="SELECT Max(ID)+1 As MaxID FROM tblError";
         rs = stmt.executeQuery(sql);
    My only idea is to tokenize the string to retrieve only the numeric part, then add +1 to this number, and finally concatenate back onto the
    String. My problem is that I cannot find any remotely good examples as to how seperate this String. Could someone please offer a good string tokenization example to seperate 'CB-01' into 'CB-' and '01'. Unless of course there is an easier way to do this. Thanks.

    Hi picmann,
    The solution may depend on your SQL server.
    SQL Server, for instance, has substring() and charindex() functions.
    select max(substring(id, charindex(id, '-') + 1, 255)) from ...
    /* if expresion doesn't translate to numeric then: */
    select max(convert(int, substring(id, charindex(id, '-') + 1, 255))) from ...
    The result will contain only the numerical part, add 1 and concatenated to the prefix.

  • Null String and Empty String problem

    Hello everyone,
    since i am totally new in JSP, i am getting problem in handling strings.
    Suppose i have a variable users = ""; then
    I want to ask when to use:
    if (users.equals(""))
    and
    if(users == "")
    in my code, variable users has value "regional" for regional users.
    and i am checking this code as:
    if (users.equals{"regional")) {
    out.print ("I am inside code");
    at that time, the code is throwing error (run time error)
    and when i changed the code as:
    if (users == "regional") {
    out.print ("I am inside code");
    this time, the code is not generating error but the part message "I am inside code " is not displaying. The code do not inserts inside the if condition
    I hope u understand my problem. Can anybody help me out with this.

    This has basically nothing to do with JSP, but with basic Java knowledge.
    When using the '==' operator to compare Objects (yes, String is actually a subclass of Object), then it will look if they are of the same reference. Using the '==' operator to compare primitive datatypes (int, boolean, char, etc) will look if they have the same value.
    That is why the Object class has the equals() method to give the ability compare with another objects. And you can only invoke it when the Object is actually instantiated. So if it is not null.
    if (string != null && string.equals("somevalue")) {
    // or
    if ("somevalue".equals(string)) {
    }should work.
    Edit rym82: this will not throw a NPE, but an ordinary compilation error ;)
    Message was edited by:
    BalusC

  • POI getCellStyle and empty string problem

    I'm having a problem getting the style of a cell from and excel input file and setting to an output file.
    I also have a problem recognizing blank cells that are not null in the input file here is my code any help would be great.
    package Trace;
    import java.io.*;
    import org.apache.poi.hssf.usermodel.*;
    import org.apache.poi.hssf.util.HSSFColor;
    import java.util.StringTokenizer;
    import org.apache.poi.poifs.filesystem.*;
    import java.lang.Runtime;
    public class Converter1 {
         private static short bhyvb= 0;
         private static short foreground, background;
         private static String[][] cellGridOut;
         private static int numRows, numColumns, clock;
         private static POIFSFileSystem fs;
         private static HSSFWorkbook wbin, wbout;
         private static HSSFSheet sheetIn, sheetOut;
         private static HSSFRow rowIn, rowOut;
         private static HSSFCell cellIn, cellIn1, cellOut;
         private static FileOutputStream fileOut = null;
         private static String rowIterator, rowIterator1;
         private static HSSFCellStyle style, style1;
         public static void main(String[] args) {
              //Take in 2 inputs mandatory, Input Event Trace excel file and Time Interval respectively
              if (args.length != 1)System.err.println("Input Excel File"); 
              //Create a new POI file system and HSSF workbook with your excel input file
              InputStream input = Converter.class.getResourceAsStream(args[0]);
              try{
                   fs = new POIFSFileSystem(input);
                   wbin = new HSSFWorkbook(fs);
              }catch (Exception e){System.err.println("File input error");}
              wbout = new HSSFWorkbook();
              sheetIn = wbin.getSheetAt(0);
              numRows = sheetIn.getLastRowNum();//numRows=723
              style = wbout.createCellStyle();
              //style.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
              //style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
              //get number of columns
              rowIn = sheetIn.getRow(0);
              boolean done = false;
              int testNullPointer;
              numColumns=0;
              while(!done){
                   //System.out.println(ColumnInc);
                   cellIn = rowIn.getCell((short)numColumns);
                   numColumns+=1;
                   try{
                        testNullPointer = cellIn.getCellType();
                   }catch(NullPointerException npe){
                        done = true;
              numColumns-=1; //number of columns = 25
              converterIt();
              //Create new output file, if it exists delete it
              File myFile = new File("converted.xls"); 
              if(myFile.exists()){
                   myFile.delete();
              //Create new file output stream
              try {
                   fileOut = new FileOutputStream(myFile);
              } catch (IOException ioe) {}
              //write all conversion data to output file
              try{ 
                   wbout.write(fileOut);
                   fileOut.close();
              }catch (IOException ioe) {} 
         public static void converterIt(){
              boolean nextDone = false;
              boolean nextDone1 = false;
              for(int i=0; i<numColumns; i++){
                   clock =1;
                   rowIn = sheetIn.getRow(0);
                   cellIn = rowIn.getCell((short)i);
                   String getTopRow = cellIn.getStringCellValue();
                   sheetOut = wbout.createSheet(getTopRow+"_s"+i);
                   sheetOut.setColumnWidth((short)0, (short)(13 * 256));
                   sheetOut.setDefaultColumnWidth((short)25);
                   for(int j=0; j<=numRows; j++){
                        if(j==0){
                             rowIn = sheetIn.getRow(j);
                             cellIn = rowIn.getCell((short)i);
                             String temp2 = cellIn.getStringCellValue();
                             rowOut = sheetOut.createRow((short)j);
                             cellOut = rowOut.createCell((short)j);
                             cellOut.setCellValue(temp2);
                             cellOut = rowOut.createCell((short)(j+1));
                             cellOut.setCellValue("CLOCK");
                        if(j==1){
                             rowIn = sheetIn.getRow(j);
                             cellIn = rowIn.getCell((short)i);
                             double temp3 = cellIn.getNumericCellValue();
                             rowOut = sheetOut.createRow((short)j);
                             cellOut = rowOut.createCell((short)0);
                             cellOut.setCellValue(temp3);
                             cellOut = rowOut.createCell((short)1);
                             cellOut.setCellValue("");
                        nextDone=false;
                        nextDone1=false;
                        if(j>1){
                             rowIn = sheetIn.getRow(j);
                             try{
                                  cellIn = rowIn.getCell((short)i);
                             }catch(NullPointerException npe){
                                  rowIterator = "";
                                  nextDone=true;
                             if(!nextDone){
                                  try{
                                       rowIterator = cellIn.getStringCellValue();
                                       style = cellIn.getCellStyle();
                                  }catch(NullPointerException npe){}
                             if(j==2){
                                  rowOut = sheetOut.createRow((short)(clock+1));
                                  cellOut = rowOut.createCell((short)0);
                                  cellOut.setCellValue(rowIterator);
                                  cellOut = rowOut.createCell((short)1);
                                  cellOut.setCellValue(j-1);
                                  clock+=1;
                             }else{
                                  rowIn = sheetIn.getRow(j-1);
                                  try{
                                       cellIn = rowIn.getCell((short)i);
                                  }catch(NullPointerException npe){
                                       rowIterator1 = "";
                                       nextDone1=true;
                                  if(!nextDone){
                                       try{
                                            rowIterator1 = cellIn.getStringCellValue();
                                       }catch(NullPointerException npe){}
                             if(rowIterator1!=rowIterator && j>2){
                                  rowOut = sheetOut.createRow((short)clock+1);
                                  cellOut = rowOut.createCell((short)0);
                                  cellOut.setCellValue(rowIterator);
                                  //System.out.println(style);
                                  cellOut.setCellStyle(style);
                                  cellOut = rowOut.createCell((short)1);
                                  cellOut.setCellValue(j-1);
                                  clock+=1;
                        }//if
                   }//for
              }//for
         }//converterIt
    }//Converter1 CLASSEND

    I am not sure about the cell style as it looks like you are doing it right. For the null or blank cells it looks like you are only checking for null not "".

  • Search and replace string problems

    Hi to all,
    I have problem with Search and replace string function. It shows me a wrong Value (Number) from 15 to 100 is everything OK (15=0, 30=1, 45=2, 100=3), but after 100 ........
    Take look in VI and if you have any ideas post them please
    THX
    Igor 
    Attachments:
    indexing.vi ‏10 KB

    there will be no 15115 string, but 15 or 115 and 15 is 0, 115 is 4. Anyway, i have changed string input format and now its working THX for your help
    Attachments:
    indexing.vi ‏10 KB

  • #Name in Access table - Connection string problem

    Dear All,
    Hope you can help with this one. I am using the 9.0.1.8 ODBC driver set to connect to our Oracle817 database. Usually when connecting tables everything is fine, and no problems appear. There are, however, a small handful of tables that cause ODBC Call Failed errors when I attempt to connect and open them, they display an incorrect record count, and fill all columns with #Name.
    After checking someone else's PC, I have found that the problem is caused by the connection string. Obviously the connection string is genereated from the setting used in the ODBC Admin panel, but how do I get it to include or exclude the settings that are causing the problems?
    With thanks in advance,
    Paul.

    The Application Name is used for the database administrator to see the name of the application that is connecting to SQL Server. If it is not provided, the default value is '.NET SQLClient Data Provider'.

  • Webutil invoke.string problem with c++

    hi ,
    am using forms 10g and trying to call a dll in c++
    it works when i call the dll using webutil to return an integer from the dll by sending 2 parameters of type varchar2
    to invoke the function returning integer
    rc1 := WEBUTIL_C_API.Invoke_int('cards_dll.dll','Retrieving',args);     
    but when i try to return string an error occurs from the exception because oracle cant understand the type returned from c++ dll
    this is my code in c++ wish is correct
    am sending one parameter in my parameter list of type varcahar2 and i want to return a string from c
    f_handle      := WEBUTIL_C_API.register_function('cards_dll.dll','Retrieving');
    args      := WEBUTIL_C_API.create_parameter_list;
    param1      := WEBUTIL_C_API.add_parameter(args,WEBUTIL_C_API.C_CHAR_PTR,WEBUTIL_C_API.PARAM_IN ,x,6);
    rc1 := WEBUTIL_C_API.Invoke_string('cards_dll.dll','Retrieving',args);     -----here is the problem
    WEBUTIL_C_API.Destroy_Parameter_List(args);
    WEBUTIL_C_API.Deregister_Function(f_handle);                                                                                
    return rc1;
    EXCEPTION
         WHEN OTHERS THEN
         MESSAGE('ERROR:' || ERROR_TEXT);
         FOR I IN 1..Tool_Err.Nerrors
         LOOP
              message (Tool_Err.Message);PAUSE;
              Tool_Err.Pop;
         END LOOP;
    END ;
    in c++dll
    am using
    extern "C" __declspec(dllexport) LPCSTR __cdecl Retrieving(LPCSTR com_reader);
    //it means return longpointer and receive long pointer in com_reader
    LPCSTR result ;
    RESULT = "JIHAD abou ghannam 10081977 august10" as example
    return RESULT;
    what should i do to receive jihad in forms 10g.
    note i can get back an integer using extern "C" __declspec(dllexport) int __cdecl Retrieving(LPCSTR com_reader);
    but not a string so its not a hardware or web problem its a type problem i think, no?
    there is another way to use other than invoke.string in oracle or i have to change the type LPCSTR IN C++?

    hi ,
    am using forms 10g and trying to call a dll in c++
    it works when i call the dll using webutil to return an integer from the dll by sending 2 parameters of type varchar2
    to invoke the function returning integer
    rc1 := WEBUTIL_C_API.Invoke_int('cards_dll.dll','Retrieving',args);     
    but when i try to return string an error occurs from the exception because oracle cant understand the type returned from c++ dll
    this is my code in c++ wish is correct
    am sending one parameter in my parameter list of type varcahar2 and i want to return a string from c
    f_handle      := WEBUTIL_C_API.register_function('cards_dll.dll','Retrieving');
    args      := WEBUTIL_C_API.create_parameter_list;
    param1      := WEBUTIL_C_API.add_parameter(args,WEBUTIL_C_API.C_CHAR_PTR,WEBUTIL_C_API.PARAM_IN ,x,6);
    rc1 := WEBUTIL_C_API.Invoke_string('cards_dll.dll','Retrieving',args);     -----here is the problem
    WEBUTIL_C_API.Destroy_Parameter_List(args);
    WEBUTIL_C_API.Deregister_Function(f_handle);                                                                                
    return rc1;
    EXCEPTION
         WHEN OTHERS THEN
         MESSAGE('ERROR:' || ERROR_TEXT);
         FOR I IN 1..Tool_Err.Nerrors
         LOOP
              message (Tool_Err.Message);PAUSE;
              Tool_Err.Pop;
         END LOOP;
    END ;
    in c++dll
    am using
    extern "C" __declspec(dllexport) LPCSTR __cdecl Retrieving(LPCSTR com_reader);
    //it means return longpointer and receive long pointer in com_reader
    LPCSTR result ;
    RESULT = "JIHAD abou ghannam 10081977 august10" as example
    return RESULT;
    what should i do to receive jihad in forms 10g.
    note i can get back an integer using extern "C" __declspec(dllexport) int __cdecl Retrieving(LPCSTR com_reader);
    but not a string so its not a hardware or web problem its a type problem i think, no?
    there is another way to use other than invoke.string in oracle or i have to change the type LPCSTR IN C++?

  • String problem

    BufferedReader reader = new BufferedReader(new FileReader(new File(filie)));
    String line;
    while ((line = reader.readLine()) != null) {
    StringTokenizer st = new StringTokenizer(line, "/");
    // System.out.println("st"+st);
    String path = st.nextToken();
    String url = st.nextToken();
    String perm = st.nextToken();
    String label = path.substring(path.lastIndexOf("/"+1));
    // I cannot compile after this line. Can anyone explain me why .I am getting following exception.
    String pathToNode = path.substring(0, path.indexOf("/"));
    System.out.println("this iis test");
    //String pathToNode = path.substring(0, path.l);
    //check for the root node
    if ("top".equalsIgnoreCase(label) && pathToNode.length() == 0) {
    root = new Node(root.getLabel());
    // root.setPerm(perm);
    // root.setUrl(url);
    nodes.put(path, root);
    } else {//other node
    Node parent = nodes.get(pathToNode);
    if (parent == null) {
    System.out.println("Parent node not found");
    System.exit(-1);
    Node child = new Node(label);
    //child.setPerm(perm);
    // child.setUrl(url);
    parent.getChildren().add(child);
    nodes.put(path, child);
    reader.close();
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    I am getting an error when I am debugging pathtoNode line. I cannot debug it and I am getting above error. please help me on this problem
    thanks .
    m
    My file formate was like that
    file.txt
    /top/science/earth_science

    StringTokenizer st = new StringTokenizer(line, "/");
    String path = st.nextToken();
    // I cannot compile after this line. Can anyone explain me why .I am getting following exception.
    String pathToNode = path.substring(0, path.indexOf("/"));When you take path out of a StringTokenizer that delimits at slashes, how do you expect path to contain a slash?

  • String problem in web tutorial

    HI,
    I tried to create the web tutorial, the first step, that is to put a label, text field, button and static text.
    This line is my problem in the helloButton action
    "String name= (String)nameField.getText();"
    I am not sure where a static text field is located on the palette. I also don't seem to be able select and name a "label" field
    joevandal

    Hi I do not see a basic palette, only a standard palette. I have looked in the help files to see if I can display a basic palette.
    I am running XP Pro . I have recreated the project several times and never have seen a basic palette. I reinstalled the Sun Java Creator.
    What gives?
    jvandal

  • String problem please help

    please help...
    String aa, bb, cc,dd;
    aa="123456789";
    bb="23";
    cc="78";
    actually i want to cut off some special words in a String
    i use
    int ak3=aa.indexOf(bb);
    int ak4=aa.lastIndexOf(bb);
    dd=aa.substring(ak3,ak4);
    i want the result of dd is 14569
    is there any problem
    please help

    Here is a better version of the code I posted earlier. This version ensures that bb and cc are contained within aa.
    The following case will still cause a problem...
    aa = "123456789";
    bb = "34";
    cc = "45";
    cc will not be found because the removal of bb took out the 4 needed to complete cc.
    public class MySubString
        public MySubString()
        public static void main (String [] args)
            String aa = new String ("123456789");
            String bb = new String ("88");
            String cc = new String ("23");
            String dd = aa;
            if (aa.indexOf(bb) >= 0)    // check to see that bb is contained within aa
                // use parts of aa from beginning of aa to beginning of bb as well as
                // end of bb to end of aa
                dd = aa.substring(0, aa.indexOf(bb)) + aa.substring(aa.indexOf(bb)+bb.length());
            if (dd.indexOf(cc) >= 0)    // check to see that cc is contained within dd
                // use parts of dd from beginning of dd to beginning of cc as well as
                // end of cc to end of dd
                // use dd in this section, because cc may appear before or after bb in aa
                dd = dd.substring(0, dd.indexOf(cc)) + dd.substring(dd.indexOf(cc)+cc.length());
            System.out.println(dd);
    }

  • String problem java.lang.NullPointerException

    Hii all :)
    How are u?? :)
    I have a little a problem with String object in this class (You can say its a homework ^__^ ).
    public class Personne {
         private String nom;
         private String prenom;
         private int age;
         public Personne(){
              this(null, null, 0);
         public Personne(String nom, String prenom, int age){
              setNom(nom);
              setPrenom(prenom);
              setAge(age);
         public void setNom(String nom){
              this.nom = new String(nom);
         public void setPrenom(String prenom){
              this.prenom = new String(prenom);
         public void setAge(int age){
              this.age = age;
         public String getNom(){
              return this.nom;
         public String getPrenom(){
              return this.prenom;
         public int getAge(){
              return this.age;
         public String toString(){
              System.out.print("Nom : " + this.getNom() + ", Penom : " + this.getPrenom() + ", Age : " + this.getAge() + " ");
              return null;
    }When i call the class personne with the Personne() i get these errors in compiling-time :
    Exception in thread "main" java.lang.NullPointerException
         at java.lang.String.<init>(Unknown Source)
         at Personne.setNom(Personne.java:18)
         at Personne.<init>(Personne.java:12)
         at Personne.<init>(Personne.java:8)
         at Main.main(Main.java:4) // The line wich i inisialize my object in my main method.
    can someone help me??
    Thank you alll ^__^
    Edited by: La VloZ on 18 mai 2013 22:50
    Edited by: La VloZ on 18 mai 2013 22:51
    Edited by: La VloZ on 18 mai 2013 22:51
    Edited by: La VloZ on 18 mai 2013 22:53
    Edited by: La VloZ on 18 mai 2013 22:55

    Why the error? Because you invoke the constructor String(String s), with s null. The constructor would produce a new String with the same character sequence as s, but if s is null, it cannot do this, so it throws NullPointerException. What else could it do? Without throwing an exception, a constructor has to create a new object, but there is no raw material, so to speak, for the creation. Think what would/could you do if you had to write such a 'copy constructor' for your own class and you would be passed null.
    Now, the String copy constructor is probably useless, as the javadoc hints. When you have a String already, you don't need to create an identical one, as the original will:
    - Not be garbage collected, if you keep a reference to it
    - Never be modified, as strings are immutable
    You are right that the code you show would 'copy the reference of nom to this.nom' and this is ok. It's exactly what you need, for the reasons above.

  • Missing string problem

    So I have this piece of code to save rows of data into a text file. The problem I'm having is that some times I am missing one of the data sets from the text file. It's always the same (first column) I say about .1% of the time.
    Maybe it's just me but I really can't see why the first string would be missing. As far as I know the double going into Number to String can never be empty, right ? so the string shouldn't be empty either. I really don't see why or where the string goes missing. Maybe I'm not seeing something...
    To clirify all the other data out of the concatenate string is there except the first string, where this string goes missing I really don't know. Any input is appreciated.
    This is in LabVIEW 2010 by the way.
    Here's how the data comes out on the file:

    So here's the queue, I had to make some changes to it so I could post it but nothing related to the file management.
    Basically these are the commands I send to it during a test:
    1) DCE.Initialize (only at application initialization)
    2) DCE.Initialize.RawFile (this comes from a GUI queue)
    3) DCE.Start.SaveData (from GUI queue)
    4) DCE.Process.DataToFile (from a DAQ loop that is always running and passes the Raw Data cluster)
    5) DCE.Stop.SaveData (from GUI queue)
    6) DCE.Close.File (from GUI queue)
    Notes:
    - No other queues send messages to this queue other than the GUI and DAQ loop.
    - I did monitor the queue and there is never a backup of unprocessed elements.
    - Not sure if it matters but so far this has only happened when running as an executable.
    - Like I mentioned before this only happens in about .1% of the data sets.
    Thanks
    Attachments:
    Data Collection Queue.zip ‏87 KB

  • FindByPrimaryKey(String problem), please help

    Hi everybody.
    I'm stuck for two days on this problem, and it's so weird I simply cannot find the solution. Here's the thing:
    I have an entity EJB ProductBean with a String as a primary key (on Weblogic 8.1 server and Oracle 10g database btw). Everything mapped succesfully, everything works nicely. I made an MDB and did this
    ProductHomeLocal productHome=(ProductHomeLocal)
    jndiContext.lookup("java:comp/env/ejb/ProductHomeLocal");          
    ProductLocal pl=productHome.findByPrimaryKey("ABC");Everything works nicely. Then I changed the last line so that the search parameter isn't hardcoded but sent by a JMS message parameter, like this:
    TextMessage tm = (TextMessage) msg;
    String productId=tm.getStringProperty("productId");
    ProductHomeLocal productHome=(ProductHomeLocal)
    jndiContext.lookup("java:comp/env/ejb/ProductHomeLocal");
    ProductLocal pl=productHome.findByPrimaryKey(productId); This results in a message:
    Bean with primary key 'ABC' was not found by 'findByPrimaryKey'...Why? The table data is there, if it's hardcoded it gets found no problem, why doesn't it work like this? What am I doing wrong?
    I appreciate any kind of help. Thanks in advance.

    I thought of leading and trailing spaces, it's not
    that.
    It seems that the problem isn't in JMS message, but
    in the fact that the entity bean somehow doesn't get
    "commited". The scenario is like this:
    - session bean creates the entity bean
    - session bean puts the entity bean's ID in JMS
    message
    - MDB bean gets the message and tries to get the
    entity bean with findByPrimaryKey(ID), fails.
    I know that this has something to do with
    transactions, but I really don't know how to solve
    it..Hmmm... assumming these 2 steps are in the same method in the session bean, then here's a possible scenario that can cause your problem,
    - session bean creates the entity bean
    - session bean puts the entity bean's ID in JMS
    messagesession bean method ( <------- start of transaction boundary or join an existing one)
    create entity bean
    send message to JMS
    // some other things you want to do
    end of method ( <--- For CMT, container will commit transaction or continue with joined transaction and commit at the end )
    So mebbe your MDB is trying to locate the entity bean before the transaction is commited? How about you try this,
    1. Put the entity bean creation in its own method, say createMyEntity() and make it return the primary key on success.
    2. Set this method's tx attribute to RequiresNew.
    3. Now in your original method, call the createMyEntity method and use the returned primary key value to create your JMS message.
    4. Make the MDB tx attribute as RequiresNew also.
    Hope this helps.
    Cheers.

  • Dynamic  string problem

    Hallow I wont to do a string dynamic that when I wont to ask for relation 027 and 034 the string bring me both of relation my problem is that didn’t work what wrong.
    DATA ceck_str TYPE string.
    <b>IF switch_history = 'X' .
    ceck_str = 'relat EQ ''027'''.
    ELSE.
    ceck_str = 'relat EQ ''027'' OR relat EQ ''034'''. ENDIF.</b>
    3----select the employee who register to course--
    SELECT objid sobid priox istat endda begda
    FROM hrp1001
    INTO CORRESPONDING FIELDS OF TABLE d_itab
    FOR ALL ENTRIES IN z_course_table
    WHERE otype = 'D'
    AND objid = z_course_table-objid
    AND sclas = 'P'
    <b>AND (ceck_str).</b>
    regards

    Hi,
    IF switch_history = 'X' .
    ceck_str = 'relat EQ ''027'''.
    ELSE.
    ceck_str = 'relat EQ ''027'' OR relat EQ ''034'''. ENDIF.
    Here in below statement
    ceck_str = 'relat EQ <b>''027'''.</b>
    ceck_str = 'relat EQ <b></b>''027'' OR relat EQ ''034'''
    In ABAP " is used for comment so 027"" and 027'' OR relat EQ ''034'''
    will be considered as comment

Maybe you are looking for

  • Gmail drop-down menus (Move to, Labels) and emails and Facebook chat will not open.

    I am unable to open emails in standard Gmail. Emails can be opened after switching to the basic html version. I am also unable to use the drop-down menus, such as "Move to" or "Labels." The button turns gray, but the options do not appear. Facebook c

  • How to use a update statement which has a string containing '&' -  Pls help

    When used the following select statment in SQL plus it is working fine: SELECT * FROM REDEMPTION_OFFERS WHERE portfolio=203 AND display_description= '$100 Bed Bath'||' & '||'Beyond Gift Card' AND ext_redemption_type_lc = 'ERT_CERT' But when using the

  • Sentinel 7/LM: events sub-queries, DB queries...

    Hi, Im using Sentinel 7 but I think that SLM works at the same way. I have an IDM workflow with tree forms: request, approval1 and approval2. I need show all the history based on my activities, ie: Activity0: requested by user1, date, request text; A

  • DBMS_HS_PASSTHROUGH Example.

    Hi All, Can anyone help me with the Example of DBMS_HS_PASSTHROUGH 1, I have Oracle Table Temp1 columns: Name, ID in Server A. 2, ACCESS DATABASE DB.MDB table name TEMP1 in Server B columns Name, ID 3, I need to write a package or procedure to insert

  • Missing common features or just blind?

    First, will Apple allow Gmail to be pushed like all the other services as opposed to the 15 min intervals which is the most frequent allowed or is that just the intended deterrent for Gmail user to sway from Google products and services? Phones I was