Error in StringTokenizer

I am trying to run this code that I got from a textbook. The only thing that I changed was the name of the file that was to be read in. It was "inventory.dat" and I changed it to "clients.txt".
The code compiled fine but when I went to run it I got the following error:
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknown Source)
at CheckInventory.man(CheckInventory.java:34)
What does this error mean? And why didn't it work? I took it right out of my textbook. Any insight would be appreciated.
//  CheckInventory.java       Author: Lewis/Loftus
//  Demonstrates the use of a character file input stream.
import java.io.*;
import java.util.StringTokenizer;
public class CheckInventory
   //  Reads data about a store inventory from an input file,
   //  creating an array of InventoryItem objects, then prints them.
   public static void main (String[] args)
      final int MAX = 100;
      InventoryItem[] items = new InventoryItem[MAX];
      StringTokenizer tokenizer;
      String line, name, file = "clients.txt";
      int units, count = 0;
      float price;
      try
         FileReader fr = new FileReader ("clients.txt");
         BufferedReader inFile = new BufferedReader (fr);
         line = inFile.readLine();
         while (line != null)
            tokenizer = new StringTokenizer (line);
            name = tokenizer.nextToken();
            try
               units = Integer.parseInt (tokenizer.nextToken());
               price = Float.parseFloat (tokenizer.nextToken());
               items[count++] = new InventoryItem (name, units, price);
            catch (NumberFormatException exception)
               System.out.println ("Error in input. Line ignored:");
               System.out.println (line);
            line = inFile.readLine();
         inFile.close();
         for (int scan = 0; scan < count; scan++)
            System.out.println (items[scan]);
      catch (FileNotFoundException exception)
         System.out.println ("The file " + file + " was not found.");
      catch (IOException exception)
         System.out.println (exception);
//  InventoryItem.java       Author: Lewis/Loftus
//  Represents an item in the inventory.
import java.text.DecimalFormat;
public class InventoryItem
   private String name;
   private int units;    // number of available units of this item
   private float price;  // price per unit of this item
   private DecimalFormat fmt;
   //  Sets up this item with the specified information.
   public InventoryItem (String itemName, int numUnits, float cost)
      name = itemName;
      units = numUnits;
      price = cost;
      fmt = new DecimalFormat ("0.##");
   //  Returns information about this item as a string.
   public String toString()
      return name + ":\t" + units + " at " + price + " = " +
             fmt.format ((units * price));
}clients.txt
Widget 14 3.35
spoke 132 0.32
wrap 58 1.92
thing 28 4.17

when I went to run it I got the following error:
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknown Source)
at CheckInventory.man(CheckInventory.java:34)
What does this error mean?It means that when you called nextToken() there weren't any more tokens. In other words the input line didn't contain as many tokens as you expected.

Similar Messages

  • Error with StringTokenizer

    hi, i am receiving the following error message:
    MyBot.java:611: cannot resolve symbol
    symbol: class StringTokenizer
    location: class MyBot
              StringTokenizer t = new StringTokenizer(s,"@");
    repeated twice, with one arrow pointing at the first mention
    of StringTokenizer and the other arrow at the other mention.
    The file MyBot.java has the following import clauses:
    import java.util.Date;
    import java.util.Random;
    import java.io.*;
    import GooglePack.*;
    import java.lang.*;
    which i thought were sufficient for StringTokenizer,
    but obviously not :(
    i use StringTokenizer as follows:
    StringTokenizer t = new StringTokenizer(s,"@");     
    String rnick = t.nextToken();
    String rhost = t.nextToken();
    String rdate = t.nextToken();
    String reol = t.nextToken();
    Any help would be much appreciated,
    cameron

    Always use the java documentation bundle for the SDK. You can look up a class for free in an indexed HTML and see all the fields, methods, constructors, related classes and yes, it's package.
    Talden

  • Java.util.NoSuchElementException

    Hi friends,
    I am retrieving data from SAP to mysql table..
    While doing that i am getting the error of java.util.NoSuchElementException.
    Exact code which error is getting is
    count++;
                        for(com.sap.mw.jco.JCO.FieldIterator fI = tableList.fields(); fI.hasMoreElements(); mb.append("\r\n"))
                            com.sap.mw.jco.JCO.Field tabField = fI.nextField();
                            data = tabField.getString();
                            error = data;
                            StringTokenizer st = new StringTokenizer(data, "|");
                            mb.append("|");
                            for(int i = 0; i < rec_count; i++)
                                try
                                    String tempdata = st.nextToken();
                                    mb.append(tempdata + "\t|");
                                    tempdata = mysap.replace(tempdata, "\\", "\\\\");
                                    sapdata[i] = mysap.replace(tempdata, "'", "\\'");
                                   // System.out.println("Java memory in use = " + ((Runtime.getRuntime().totalMemory()) - (Runtime.getRuntime().freeMemory())));
                                catch(Exception ex1)
                                  //  sb.append("<BR>" + count + "[" + i + "]" + ex1.toString());
                                    System.out.println("Error insertData module:" +"<br>");
                                    System.out.println("<BR>" + count + "[" + i + "]" + ex1.toString());
                        }some part of error is
    Error insertData module:<br>
    <BR>488[10]java.util.NoSuchElementException
    Error insertData module:<br>
    <BR>563[10]java.util.NoSuchElementException
    Error insertData module:<br>
    <BR>700[10]java.util.NoSuchElementException
    Error insertData module:<br>
    <BR>1080[10]java.util.NoSuchElementException
    Error insertData module:<br>
    <BR>1081[10]java.util.NoSuchElementException
    Error insertData module:<br>
    <BR>1110[10]java.util.NoSuchElementException
    Error insertData module:<br>
    <BR>1112[10]java.util.NoSuchElementException
    Error insertData module:<br>
    etc...
    Please help me sort out this error.I am no familier with SAP type things
    thanks in advance

    Hi paul.miner
    Thank a lot for your reply..the problem is there only.
    In SAP table some rows has 10 field values.some rows has 9 field values.So these 9 values row is creating error.Any idea to handle this situation.
    sample output
    1.data0070000205|20050114|ZDR | 12.50 |USD |SG20|10|S01|SG20|0000045934|
    Error insertData module:<br>
    <BR>3877[10]java.util.NoSuchElementException
    2.data0005000557|20050114|ZOR | 500.00 |USD |SG20|20|T01|SG21|0000045941|3000026932
    In the above first record has no last filed
    second record has one more filed.
    so fist one is creating error.Any idea to handle this....
    If i use while (st.hasMoreTokens()) instead of
    for(int i = 0; i < rec_count; i++)
    tempdata = st.nextToken();
    some other part of the program is affecting
    once again thanks

  • 2dimensional array

    Hi,
    Please help me in solving this....
    I have got a 2 dimensional string as String [ ] [ ] str = null;
    and it contains the strings as follows :
    row1 : ABCD~adfg~yuio~
    row2 : sfdfk~sdf~ds~sad~
    row3 : sa~dk~
    now i want to extract each individual string. So i use Stringtokenizer.
    now i try to copy it an array...it gives me an error.
    StringTokenizer str3 = null;
    String [ ] str4 = null;
    for (int 1=0;i<=str.length;i++)
    str2=str[0].trim();
    str3 = new StringTokenizer(str2,"~");
    while (str3.hasMoreTokens())
    // copy to a 1D array
    str4 = str3.nextToken();

    i want to extract individual strings separated by ~ in a two dimensional string array and need to put those extracted strings in an one dimensional array....do you mean 1D to 2D array?
    from:
    { "ABCD~adfg~yuio~", "sfdfk~sdf~ds~sad~", "sa~dk~ ... }
    to:
    { {"ABCD", "adfg", "yuio"},
    {"sfdfk", "sdf"... } }
    Message was edited by:
    j_shadinata

  • Printing vector

    Hi,
    Does anyone know why this generate a weird error?
    StringTokenizer strok;
    Vector temp;
    String stemp = "This is a test";
    strok = new StringTokenizer(stemp);
    temp = new Vector();
    while(strok.hasMoreTokens())
    temp.add(strok.nextToken());
    System.out.println("Vector is: " + temp.size());
    System.out.println("Vector is: " + temp);
    Here is the output:
    Vector is: 4
    Vector is: [This, is, a, test]
    Why does it have the brackets and the commas in the
    vector?
    how can I eliminate those[brackets and commas]?

    That's probably the way the println function is written for Vectors. To eliminate them, you'll probably have to use a for loop and just print out each vector element individually like this...
    for( while there's elements in the Vector )
    get the next Vector element
    Print element
    }

  • Txt file read in- StringTokenizer- Try Block Catch for errors

    Hello
    So I am having a few issues with a school project. First is with my ReadWithScanner. It does not read in the file giving me a NullPointerException error on the line <Scanner in = new>. I have tried a few other read in files and they do not seem to be working.
    I am also stuck on the logic on the try block catch statement. How does a person set up a �custom� try block that looks for errors like the ones below? I have attempted to start in the commented code.
    The text file has to read in 1000 individual lines of code and are separated by �;� and should be separated into tokens with the StringTokenizer class what I attempted to do below also. Both are mere attempts and need help�
    This is some what of the logic I thought of doing
    1.Read the first line in first with the scanner class
    2.use delimiter separated by �;�
    3.Tokenizer the line into separate tokens- invoiceCode, fName, lName�
    4.Check classes- check Name, check Date, checkPrice, checkPrice, checkGenre, checkShippingDate invoiceCode = "Error Code" checkInvoiceCode(String invoiceCode)checkName(String name), checkPrice(String price), checkGenre(String genre)
    5.Apply the regular expressions to each try block statement
    a.Assign a letter to each error for example if invoice was to short it would be assigned a letter A
    b.If invoice does have the right characters it would be assigned B
    c.If name has to few words it would be assigned D
    d.�
    This is an example of a good field from the text file
    XYG726;Smith,Mr. John M.;29.96;comedy;101008;100604
    Not so good line
    Lu15;Will, Mark;50.00;Science;030305;030807
    The file should then be printed out in the program not to a text file. It only needs to print the invoice number and error code letter assignment.
    If you have any questions feel free to let me know. Thanks for all or any help you have to offer.
    Invoice
    Three upper case letters followed by three digits
    Regular Expression "[A-Z]{3}[0-9]{3}"
    Customer Name
    Should be in the form: last name followed by a <,> optional title (Mrs. Mrs�) then first name optional middle initial Titles must be
    So regular expression something like �[a-z][A-Z]+([A-Z]{1}?[a-z][./})+[a-z][A-Z]�
    Sale Price
    Two decimal digits to the left of the decimal point. The price should not have a leading zero.
    Regular Expression [0-9]{2}*./[0-9]
    Genre
    The genre should only contain lowercase letters. Regular expression �[a-z]�
    ShipDate and Order Date-
    Must be standard dates- MMDDYY. The order date and shipping date has to be after today�s date. Regular expression �[0-9]{2}+[0-9]{2}+[0-9]{2}�
    package Project3;
    import java.util.StringTokenizer;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import java.io.*;
    import java.util.Scanner;
    public class ReadWithScanner {
    private final File fFile;
    public static void main (String args[]){
    Scanner in = new Scanner(new File("e:\\work_space_java\\Project\\Package3\\movie.txt"));
    Scanner.processLineByLine();
    public ReadWithScanner(String aFileName){
    fFile = new File(aFileName);
    public final void processLineByLine(){
    try {
    //use a Scanner to get each line
    Scanner scanner = new Scanner(fFile);
    while ( scanner.hasNextLine() ){
    processLine( scanner.nextLine() );
    scanner.close();
    catch (IOException ex){
    protected void processLine(String aLine){
    //use a second scanner again to raed the content of each line
    Scanner scanner = new Scanner(aLine);
    scanner.useDelimiter(";");
    if (scanner.hasNext() ){
    //read each file?
    String name = scanner.next();
    String value = scanner.next();
    else {
    scanner.close();
    //Token Names that are seperated
    StringTokenizer st;
    String invoiceCode = st.nextToken();
    String fname = st.nextToken();
    String lname = st.nextToken();
    String price = st.nextToken();
    String genre = st.nextToken();
    String orderDate = st.nextToken();
    String shipDate = st.nextToken();
    String invoiceCode;
    invoiceCode = "A" checkInvoiceCode(String invoiceCode);
    Pattern p = Pattern.compile("[a-z]{6}[A-Z]{6}[0-9]{6}");
    Matcher m = p.matcher(invoiceCode);
    p.matcher(invoiceCode);
    if(m.matches()) {
    System.out.println(invoiceCode);
    else {
    System.out.println ("A");
    try
    invoiceCode = Integer.parseInt(String);
    catch (NumberFormatException e)
    { System.out.println ("B"); System.exit(1); }
    */

    I have made a quite a few updates to my code. Please look it over again. I have also made many comments to help with the logic. Once again if you have any questions please feel free to ask. Sorry about not using the tags before- I was no aware of them. Thanks for the advice sabre150.
    package Project3;
    import java.util.StringTokenizer;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import java.io.*;
    import java.util.Scanner;
    public class ReadWithScanner {
         private final File fFile;
         public static void main (String args[]){
                   //read in text file from directory currently it can not read the file
                  Scanner in = new Scanner(new File("e:\\work_space_java\\Project\\Package3\\movie.txt"));
                  //Scans each line of the text in
                  Scanner.processLineByLine();
                //assigns new file name to file
                public ReadWithScanner(String aFileName){
                  fFile = new File(aFileName); 
                public final void processLineByLine(){
                  try {
                    //use a Scanner to get each line from the processLineByLine
                    Scanner scanner = new Scanner(fFile);
                    while ( scanner.hasNextLine() ){
                      processLine( scanner.nextLine() );
                    scanner.close();
                  catch (IOException ex){
                protected void processLine(String aLine){
                  //use a second scanner again to read the content of each line
                   //delmiter should then break each line in the text file into seperate "tokens"
                  Scanner scanner = new Scanner(aLine);
                  scanner.useDelimiter(";");
                  if (scanner.hasNext() ){
                       //reads each line from scanner
                    String name = scanner.next();
                  else {
                  scanner.close();
               /*Convert Tokens from Scanner into String Tokenizer with assigment to each variable
                * I am missing something
                * Need to convert each line read from the scanner (name variable) to the String
                * Tokenizer class
              //Tokens names now assigned a varaible
              StringTokenizer st;
              String invoice = st.nextToken();
              String name = st.nextToken();
              String price  = st.nextToken();
              String genre = st.nextToken();
              String orderDate = st.nextToken();
              String shipDate = st.nextToken();
          /*If statments (Try Block Statements?) with Regular Expressions
          * This is where I have the most issues on how to set up
          * "custom" try and block errors trying to match what I have
          * in the regular expressions. 
          * I believe try and catch statements
          * make this easier but I have used 'match' and 'pattern' with if
          * statments.  If try block statements are easier please show!
          * Regular Expressions may not be correct either
           invoice = checkInvoiceCode(invoice);
           //Defined cerita for Inovice are:
           //Error A = Invoice code is too short  
           //Error B = Invoice code does not have the right characters 
           //Error C = Invoice code digits are all zero
           //Checks for error A
           //Has at least six characters
            Pattern invoiceShort = Pattern.compile("{6}");
            Matcher shortInvoice = invoiceShort.matcher(invoice);
            p.matcher(invoiceCode);
            if(m.matches()) {
                 System.out.println(invoice);      
            else {
                 System.out.println ("A");
            //Checks for error B
            //3 Upper Case Letters followed by three numbers,
            Pattern rightChar = Pattern.compile("[A-Z]{3}[0-9]^0{3}");
            Matcher charRight = rightChar.matcher(invoice);
            p.matcher(invoiceCode);
            if(m.matches()) {
                 System.out.println(invoice);
            else {
                     System.out.println ("B");
            //Checks for error C
            //Where the last three digits are not all zeros
            Pattern notZero = Pattern.compile("*{3}^0{3}");
            Matcher ZeroNot = notZero.matcher(invoice);
            p.matcher(invoiceCode);
            if(m.matches()) {
                 System.out.println(invoice); 
                 else {
                     System.out.println ("C");
         //name = checkFullName(name);
         //Error D = Name field has fewer than two words
         //Error E = Name field has more than four words
         //Error F = Name field has no comma
         //Error G = Name field has a bad title 
         //Error H = Name field has a bad initial 
        /*Have a lot more to do...
        * Still need to go through the same if statement or Try Block statements with this data:
        *      String fname = st.nextToken();
              String lname = st.nextToken();
              String price  = st.nextToken();
              String genre = st.nextToken();
              String orderDate = st.nextToken();
              String shipDate = st.nextToken();
        * But for now I would like to see an example of an if statement I could use
        * (if mine is even right) or catch statement- the rest of the project we look
        * for similar certia as defined in the reg exp for invoice
         /*Writes to Report in the Console
         * Prints data into two columns:
         * Invoice Code and Error Type
         //Prints both column Headings
         private void columnHeadings ()
         System.out.println (padL("",5) +
         padL("Invoice",20) +padL("",20)+
         padL("Error Code",40));
         //movie is the name of the text file
         private void printMovie(Movie aReport) {
         System.out.println(aReport.getInvoiceCode()+"\t"+
               aReport.getErrorType()+"\t");
      *This method pads the string start to the length newLength leaving the
      *string left justified and returning the result.
      private String padL (String start, int newLength)
         String result = new String (start);
         while (result.length() <= newLength) result += " ";
         return result;
      } // end padL
       * This method pads the string start to the length newLength leaving the
       * string right justified and returning the result.
      private String padR (String start, int newLength)
         String result = new String (start);
         while (result.length() <= newLength) result = " " + result;
         return result;
    // end padRThanks a lot.

  • StringTokenizer error

    Hi,
    I am running a JSP page, which contains two HTML forms. I have given the part of the code which I am having trouble with below. The forms basically submit a field from a drop down list (call it "dropdown list 1" for explaination purposes), which according to what is selected, populates another drop down list ("dropdown list 2") further down the page. The information is extracted from an LDAP server. The problem is, the first few times I submit a field from "dropdown list 1", it populates "dropdown list 2" fine. Then, for some reason, it decides to go bang - giving me an exception:
    java.util.NoSuchElementException
    at java.util.StringTokenizer.nextToken(StringTokenizer.java
    I am not sure what is going on with my String Tokenizer instance I create in my code below called 'stbox'. I have commented the bit where things go wrong (look at the comment written in capitals). Is there something about the StringTokenizer class that I need to know about??
    <%@ page contentType="text/html" %>
    <%--//Page Directives --%>
    <%@ page language="java" %>
    <%@ page import="javax.xml.parsers.*" %>
    <%@ page import="org.w3c.dom.Document" %>
    <%@ page import="org.w3c.dom.Element" %>
    <%@ page import="org.w3c.dom.DOMException" %>
    <%@ page import="java.net.URL" %>
    <%@ page import="java.io.InputStream" %>
    <%@ page import="java.io.IOException" %>
    <%@ page import="logonBean.*" %>
    <%@ page import="java.security.*" %>
    <%@ page import="java.util.Hashtable" %>
    <%@ page import="java.util.Enumeration" %>
    <%@ page import="java.util.StringTokenizer" %>
    <%@ page import="java.util.*" %>
    <%@ page import="javax.naming.*" %>
    <%@ page import="javax.naming.directory.*" %>
    <%@ page import="javax.servlet.*" %>
    <%! public String routeURL="logon.jsp";%>
    <%! static String[] appnames = new String[40];%>
    <%! static String[] boxnames = new String[40];%>
    <%! int n=0; int flag=0; String name1 = ""; String name2 = ""; String parameterValue = ""; String parameterName="";%>
    <%! int flag1=0; int m=0; String parameterValue1 = "";%>
    <%-- //HTML Header --%>
    <html>
    <head>
    <title>Main Page</title>
    </head>
    <h1>LDAP Server Connection</h1>
    <body bgcolor="white">
    <script language='javascript'>
    function post(){
    document.forms[0].submit();
    </script>
    <FORM name=form2 id=form2 ACTION=main.jsp METHOD=POST>
    <% Hashtable env1 = new Hashtable(5, 0.75f);
    env1.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env1.put(Context.PROVIDER_URL, "ldap://boxname/dc=db,dc=com");
    try {
    DirContext ctx1 = new InitialDirContext(env1);
    SearchControls constraints1 = new SearchControls();
    constraints1.setSearchScope(SearchControls.SUBTREE_SCOPE);
    //instead of ou=WebSSO, take user input to determine value into variable
    NamingEnumeration box_results = ctx1.search(ou + ", ou=Application", "(boxname=*)", constraints1);
    m=0;
    while(box_results != null && box_results.hasMore()) {
    SearchResult search = (SearchResult)box_results.next();
    String box = search.getName();
    StringTokenizer stbox = new StringTokenizer(box, "=");
    while(stbox.hasMoreElements()){
    //GOING WRONG DOWN HERE!!! WORKS FOR A WHILE THEN CAUSES AN ERROR!!!!!!
    String box1 = stbox.nextToken();
    String box2 = stbox.nextToken();
    boxnames[m] = box2;
    System.out.println(boxnames[m]+" , ");
    m++;
    //Exception Handling
    }//end of try
    catch(NamingException e)
    e.printStackTrace();
    parameterValue1 = request.getParameter("App");
    %>
    <br><br><br>
    <TR> <TD> Choose a Unix Box for the Application selected</TD>
    <TD> <SELECT onSelect='javascript ost()' NAME=Box>
    <% if(parameterValue1==null){%>
    <OPTION selected>-------Select Value-------</OPTION>
    <%}else {%>
    <OPTION>-------Select Value-------</OPTION>
    <%}
    int l=0;
    while(boxnames[l]!=null){
    if(boxnames[l].equals(parameterValue1)){
    %>
    <OPTION selected><%=boxnames[l]%></OPTION>
    <%}else{%>
    <OPTION><%=boxnames[l]%></OPTION>
    <%}
    l++;
    %>
    </SELECT></TD>
    </TR>
    <INPUT TYPE=SUBMIT VALUE="Submit BOXNAME">
    </FORM>
    <HR>
    <B>Box Selected</B><BR>
    <TABLE>
    <%
    Enumeration parameter1 = request.getParameterNames();
    parameterValue1 = request.getParameter("Box");
    %>
    <TR>
    <TD><%=parameterValue1%></TD>
    </TR>
    <%
    %>
    </TABLE>
    </body>
    </html>
    Thankyou for your help guys.
    Kamal.

    Hi Kamal,
    the pb is that u call 2 times stbox.nextToken() in the same loop
    what u have to do is :
    String box2;
    String box1 = stbox.nextToken();
    if (stbox.hasMoreElements()) {
    box2 = stbox.nextToken(); anyway i don't understand why u call 2 times nextToken() in the same loop, plus u dont use box1.
    hope it helps.
    L/\s3R

  • StringTokenizer error in JSP

    Hi,
    I am running a JSP page, which contains two HTML forms. I have given the part of the code which I am having trouble with below. The forms basically submit a field from a drop down list (call it "dropdown list 1" for explaination purposes), which according to what is selected, populates another drop down list ("dropdown list 2") further down the page. The information is extracted from an LDAP server. The problem is, the first few times I submit a field from "dropdown list 1", it populates "dropdown list 2" fine. Then, for some reason, it decides to go bang - giving me an exception:
    java.util.NoSuchElementException
    at java.util.StringTokenizer.nextToken(StringTokenizer.java
    I am not sure what is going on with my String Tokenizer instance I create in my code below called 'stbox'. I have commented the bit where things go wrong (look at the comment written in capitals). Is there something about the StringTokenizer class that I need to know about??
    <%@ page contentType="text/html" %>
    <%--//Page Directives --%>
    <%@ page language="java" %>
    <%@ page import="javax.xml.parsers.*" %>
    <%@ page import="org.w3c.dom.Document" %>
    <%@ page import="org.w3c.dom.Element" %>
    <%@ page import="org.w3c.dom.DOMException" %>
    <%@ page import="java.net.URL" %>
    <%@ page import="java.io.InputStream" %>
    <%@ page import="java.io.IOException" %>
    <%@ page import="logonBean.*" %>
    <%@ page import="java.security.*" %>
    <%@ page import="java.util.Hashtable" %>
    <%@ page import="java.util.Enumeration" %>
    <%@ page import="java.util.StringTokenizer" %>
    <%@ page import="java.util.*" %>
    <%@ page import="javax.naming.*" %>
    <%@ page import="javax.naming.directory.*" %>
    <%@ page import="javax.servlet.*" %>
    <%! public String routeURL="logon.jsp";%>
    <%! static String[] appnames = new String[40];%>
    <%! static String[] boxnames = new String[40];%>
    <%! int n=0; int flag=0; String name1 = ""; String name2 = ""; String parameterValue = ""; String parameterName="";%>
    <%! int flag1=0; int m=0; String parameterValue1 = "";%>
    <%-- //HTML Header --%>
    <html>
    <head>
    <title>Main Page</title>
    </head>
    <h1>LDAP Server Connection</h1>
    <body bgcolor="white">
    <script language='javascript'>
    function post(){
    document.forms[0].submit();
    </script>
    <FORM name=form2 id=form2 ACTION=main.jsp METHOD=POST>
    <% Hashtable env1 = new Hashtable(5, 0.75f);
    env1.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env1.put(Context.PROVIDER_URL, "ldap://boxname/dc=db,dc=com");
    try {
    DirContext ctx1 = new InitialDirContext(env1);
    SearchControls constraints1 = new SearchControls();
    constraints1.setSearchScope(SearchControls.SUBTREE_SCOPE);
    //instead of ou=WebSSO, take user input to determine value into variable
    NamingEnumeration box_results = ctx1.search(ou + ", ou=Application", "(boxname=*)", constraints1);
    m=0;
    while(box_results != null && box_results.hasMore()) {
    SearchResult search = (SearchResult)box_results.next();
    String box = search.getName();
    StringTokenizer stbox = new StringTokenizer(box, "=");
    while(stbox.hasMoreElements()){
    //GOING WRONG DOWN HERE!!! WORKS FOR A WHILE THEN CAUSES AN ERROR!!!!!!
    String box1 = stbox.nextToken();
    String box2 = stbox.nextToken();
    boxnames[m] = box2;
    System.out.println(boxnames[m]+" , ");
    m++;
    //Exception Handling
    }//end of try
    catch(NamingException e)
    e.printStackTrace();
    parameterValue1 = request.getParameter("App");
    %>
    <br><br><br>
    <TR> <TD> Choose a Unix Box for the Application selected</TD>
    <TD> <SELECT onSelect='javascript ost()' NAME=Box>
    <% if(parameterValue1==null){%>
    <OPTION selected>-------Select Value-------</OPTION>
    <%}else {%>
    <OPTION>-------Select Value-------</OPTION>
    <%}
    int l=0;
    while(boxnames[l]!=null){
    if(boxnames[l].equals(parameterValue1)){
    %>
    <OPTION selected><%=boxnames[l]%></OPTION>
    <%}else{%>
    <OPTION><%=boxnames[l]%></OPTION>
    <%}
    l++;
    %>
    </SELECT></TD>
    </TR>
    <INPUT TYPE=SUBMIT VALUE="Submit BOXNAME">
    </FORM>
    <HR>
    <B>Box Selected</B><BR>
    <TABLE>
    <%
    Enumeration parameter1 = request.getParameterNames();
    parameterValue1 = request.getParameter("Box");
    %>
    <TR>
    <TD><%=parameterValue1%></TD>
    </TR>
    <%
    %>
    </TABLE>
    </body>
    </html>
    Thankyou for your help guys.
    Kamal.

    while(stbox.hasMoreElements()){
    //GOING WRONG DOWN HERE!!! WORKS FOR A WHILE THEN CAUSES AN ERROR!!!!!!
    String box1 = stbox.nextToken();
    String box2 = stbox.nextToken();
    stbox may not have more than one token ... In that case it'll throw an exception ... either you call stbox.nextToken() once or change the logic with a if check for the second call ....
    Hope this helps ..

  • Program will run with errors, but not at all in a .jar file

    First off, here is my program right now:
    import java.io.*;
    import java.util.*;
    import javax.swing.JOptionPane;
    public class prune
        public static void main(String args[])
            String steamid="",time="";
            BufferedReader infile = null;
            BufferedWriter outfile = null;
            FileReader fr = null;
            FileWriter wr = null;
            StringTokenizer strtk = null;
            String line = null;
         JOptionPane.showMessageDialog
          (null, "Vault.ini Pruner v2");
         String filepath = JOptionPane.showInputDialog("Enter the filepath to your vault.ini file.");
         String strdeletenumber = JOptionPane.showInputDialog("Enter the number that vault entries under will be deleted");
         int deletenumber = Integer.parseInt(strdeletenumber);
            try
                infile = new BufferedReader(new FileReader(filepath));
                outfile = new BufferedWriter(new FileWriter(filepath));
            catch(IOException ioe)
                JOptionPane.showMessageDialog
          (null, "Can't open vault.ini:" + ioe);
            try
                while((line=infile.readLine())!=null)
                    strtk = new StringTokenizer(line);
                    steamid = strtk.nextToken();
                    time = strtk.nextToken();
                    if(Integer.parseInt(time)>=deletenumber)
                        outfile.write(steamid);
                        outfile.write(" ");
                        outfile.write(time);
                        outfile.newLine();
            catch(IOException ioe)
                JOptionPane.showMessageDialog
          (null, "Error:" + ioe);
            try
                outfile.close();
                infile.close();
            catch(IOException ioe)
               JOptionPane.showMessageDialog
          (null, "Error:" + ioe);
                System.exit(0);
    }The program is supposed to open a vault.ini file and delete entries with a number lower than specified.
    Vault files are set up like this:
    STEAMID:X:XXXX 100000
    Right now if I run the program through command prompt it erases both the vault.ini and new vault.ini. I am also trying to put it in an executable jar file and when I do that I get a "Failed to load main class manifest attribute" error. Any ideas on what is causing this?

    I don't know what is happening. I put your exact code into a small build environment and used a build file for ant that I have and it works just fine. Manifest files are a total pain which is why I use a tool to generate it. I know that the last line has to be blank and that no line can be over a certain length.
    You've now spent several days avoiding ant and I got it running with ant in about 3 minutes. I'm really missing something.
    For reference, the build file is below should you change your mind. Put your prune.java in a new directory named "src" and save this file below as build.xml in the parent directory of "src". Run the program with java -jar lib/prune.jar
    <project name="jartest" default="main" basedir=".">
    <!-- location properties -->
        <property name="src.dir" location="src" />
        <property name="dest.classes.dir" location="classes" />
        <property name="dest.lib.dir" location="lib" />
    <!-- value properties -->
        <property name="dest.lib.name" value="prune.jar" />
        <property name="main.class" value="prune" />
    <!-- compile time value properties -->
        <property name="compile.debug" value="true" />
        <property name="compile.optimize" value="false" />
        <property name="compile.deprecation" value="true" />
        <property name="compile.source" value="1.4"/>
        <property name="compile.target" value="1.4"/>
    <!-- build -->
        <target name="main" depends="compile,jar" />
        <target name="compile">
            <mkdir dir="${dest.classes.dir}"/>
            <mkdir dir="${dest.lib.dir}"/>
            <javac srcdir="${src.dir}"
                         destdir="${dest.classes.dir}"
                         debug="${compile.debug}"
                         deprecation="${compile.deprecation}"
                         optimize="${compile.optimize}"
                         source="${compile.source}"
                         target="${compile.target}" >
            </javac>
        </target>
    <!-- clean -->
        <target name="clean">
            <delete dir="${dest.classes.dir}"/>
            <delete dir="${dest.lib.dir}"/>
        </target>
    <!-- jar -->
        <target name="jar" depends="compile">
            <jar destfile="${dest.lib.dir}/${dest.lib.name}"
                    basedir="${dest.classes.dir}">
                <manifest>
                    <attribute name="Built-By" value="${user.name}"/>
                    <attribute name="Main-Class" value="${main.class}" />
                </manifest>
            </jar>
        </target>
    </project>

  • Stringtokenizer, swing and memory

    i lately found that the stringtokenizer eats up lots of memory, i tried to set vars to null and called sys gc quite often but they didnt seem to be of much help.
    ok, here is what i was doing: i read in a quite a big txt file, about 400k lines, and then parsed each line using stringtokenizer, everything happened in while loops, lots of objects but all small ones. i had to xmx lots of memories to it in order to run it. and it became much worse when i put it into multi threaded swing app. if you are a swing expert, or stringtokenizer expert, please shed some light.

    Dang it! Sun zapped a bunch of posts!
    Anyway, here again is a sample pgm posted earlier (which got zapped) showing some of the benefits of the finally block, for which the idiot daFei could not come up with an intelligent answer to refute it (he STILL has a beef with the finally block, claiming it is only "syntactic sugar", and still moronically implies that all methods must handle all exceptions, which is absurd in that no exceptions could ever be THROWN then!)
    import java.io.File;
    import java.io.IOException;
    class SillyQuestionException extends Exception {
      public SillyQuestionException() {
        super("That's a silly question.  Of course!");
    class Guru {
       * Responds to a question/statement.  A temporary file is created
       * during execution, and deleted upon return (unless daFei dorks
       * with the implementation!)
       * @param request the question/statement for Guru to respond to
       * @return the Guru's response
       * @throws SillyQuestionException if the Guru determines you're
       * asking a silly question,
       * to which the answer should be obviously YES
      public static String respond(String request)
        throws SillyQuestionException {
        File f = new File("daFei.is.an.idiot");
        try {
          System.out.println("  Guru is thinking...");
          f.createNewFile();
          // let's just assume we needed to write stuff to this file in
          // order to process the request...
          // now the actual end of processing
          if ("is daFei an idiot".equals(request))
            throw new SillyQuestionException();
        catch (IOException e) {
          System.out.println("Error occurred creating/writing to " +
            "temp file, but graceful recovery is possible");
          e.printStackTrace();
          return "I'll have to get back to you on that one.  " +
            "Ask me again later.";
        finally {
          // this is NECESSARY to GUARANTEE deletion of the temp file,
          // otherwise this statement would have to be duplicated at all
          // possible return points.
          System.out.println("  Guru has processed your request...");
          if (f != null)
            f.delete();
        System.out.println("  will this get printed EVERY time?  " +
          "NO IT WILL NOT!");
        return "daFei has fish turds in his brain";
    public class Demo {
      public static void main(String[] args) {
        String[] questions = {
          "what statement best describes daFei",
          "what kind of turds does daFei have in his brain",
          "is daFei an idiot",
          "won't get to this question"
        try {
          for (int i = 0; i < questions.length; ++i) {
            System.out.println("Question: " + questions);
    System.out.println("Response: " + Guru.respond(questions[i]));
    catch (SillyQuestionException e) {
    System.out.println("I have finally asked the Guru a silly " +
    "question, and will stop now");
    System.out.println("Here's what Guru had to say to the last " +
    "question: " + e);

  • FileReader and StringTokenizer

    what I'm trying to do is to read String and Double date in a txt document here my code:
    import java.io.*;
    import java.util.*;
    public class partie1 {
         static final int limite_colones=10;
         static final int limite_lignes=10;
         static final int limite_matieres=5;
         static final int limite_eleves=15;
         static final String titre="�cole secondaire Cartierville";
         static String nomEleve[]=new String[limite_eleves];
         static double notesEleve[][]=new double[limite_eleves][limite_matieres];
         public static void main(String[] args)throws IOException {
              String ligne,ficEleve="c:/ficEleves.txt";
              BufferedReader ficnomlogique=new BufferedReader(new FileReader(new File(ficEleve)));
              while ((ligne=ficnomlogique.readLine())!=null){
                   StringTokenizer ligneTemp=new StringTokenizer (ligne,":");
                   for(int i=0;i<15;i++){
                        nomEleve=ligneTemp.nextToken();
                        System.out.println(nomEleve[i]);
                        for(int j=0;j<5;j++){
                             notesEleve[i][j]=Double.parseDouble(ligneTemp.nextToken());
                             System.out.println(notesEleve[i][j]);
    and this is what they give me as error message:
    Alain
    100.0
    90.0
    88.0
    60.0
    65.0
    Exception in thread "main" java.util.NoSuchElementException
    at java.util.StringTokenizer.nextToken(Unknow Source)
    at partiel.main(partie1.java:20)
    so i understand that it doesnt change ligne or doesnt do the for correctly but i can't figure where is my mistake.
    thank for your help

    What do the records in the file look like?
    This code:
    for(int i=0;i<15;i++){
        nomEleve=ligneTemp.nextToken();
    System.out.println(nomEleve[i]);
    for(int j=0;j<5;j++){
    notesEleve[i][j]=Double.parseDouble(ligneTemp.nextToken());
    System.out.println(notesEleve[i][j]);
    will call nextToken() on each line 15 + (15 * 5) = 90 times.
    Does each line contain 90 tokens?

  • String and stringtokenizer problem

    Hi,
    String s=new String(null);
    is it possible or not?
    StringTokenizer st=new StringTokenizer(null,",");
    is it possible or not?

    hi sudha,
    when u write
    String s=new String(null); is wrong. Just b'coz the method of String(byte()) that are from java.lang.String will match with your declared method.
    so it will have to clashing ...so u will get ERROR dear.
    Regards
    saM

  • Problem with stringtokenizer on event handling

    First of all I apologise if its not the proper area.
    I have built a typical gui with netbeans builder.When I double-click a button to switch to source and edit its actionPerformed function the first thing I do is to declare a StringTokenizer variable.I am tottaly sure that I have imported java.util package.So I ask for your help.Whats the deal and I cannot do this declaration?
    thanks in advance!
    EDIT:
    My code
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                    
       StingTokenizer stok=new StringTokenizer("kjvfw jqwejoiqe ieie9");
    }       Edited by: ultimate_aektzis on Dec 23, 2008 7:14 PM
    Edited by: ultimate_aektzis on Dec 23, 2008 7:16 PM

    Spell StringTokenizer correctly.
    (and it will help if you post the exact error message in the future.)

  • I am getting a basic error in AppletPanel.

    Hello Friends,
    I am new to Java3D. Was surfing the web to find out a way as how to have a map of a city in 3d view and came across this code by a certain Mr. Daniel Selman... I am pasting his code as well as the error i am getting when i am trying to run it using eclipse...
    Copyright (C) 2001   Daniel Selman
    First distributed with the book "Java 3D Programming"
    by Daniel Selman and published by Manning Publications.
    http://manning.com/selman
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation, version 2.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    The license can be found on the WWW at:
    http://www.fsf.org/copyleft/gpl.html
    Or by writing to:
    Free Software Foundation, Inc.,
    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    Authors can be contacted at:
    Daniel Selman: [email protected]
    If you make changes you think others would like, please
    contact one of the authors or someone at the
    www.j3d.org web site.
    * This example creates a 3D fly-over of the city of Boston. The viewer is
    * animated using a RotPosScaleTCBSplinePathInterpolator as well as 3
    * helicopters. The example uses PointSounds attached to the helicopters to
    * generate 3D spatial audio.
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Frame;
    import java.awt.GraphicsConfigTemplate;
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.InputStream;
    import java.net.URL;
    import java.util.Enumeration;
    import java.util.Vector;
    import javax.media.j3d.Alpha;
    import javax.media.j3d.Appearance;
    import javax.media.j3d.AudioDevice;
    import javax.media.j3d.Background;
    import javax.media.j3d.BackgroundSound;
    import javax.media.j3d.Behavior;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.Bounds;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.ColoringAttributes;
    import javax.media.j3d.DistanceLOD;
    import javax.media.j3d.GeometryArray;
    import javax.media.j3d.GraphicsConfigTemplate3D;
    import javax.media.j3d.Group;
    import javax.media.j3d.ImageComponent2D;
    import javax.media.j3d.Locale;
    import javax.media.j3d.MediaContainer;
    import javax.media.j3d.Node;
    import javax.media.j3d.PhysicalBody;
    import javax.media.j3d.PhysicalEnvironment;
    import javax.media.j3d.PointSound;
    import javax.media.j3d.QuadArray;
    import javax.media.j3d.Shape3D;
    import javax.media.j3d.Sound;
    import javax.media.j3d.Switch;
    import javax.media.j3d.Texture;
    import javax.media.j3d.Transform3D;
    import javax.media.j3d.TransformGroup;
    import javax.media.j3d.View;
    import javax.media.j3d.ViewPlatform;
    import javax.media.j3d.VirtualUniverse;
    import javax.media.j3d.WakeupCondition;
    import javax.media.j3d.WakeupCriterion;
    import javax.media.j3d.WakeupOnCollisionEntry;
    import javax.media.j3d.WakeupOnCollisionExit;
    import javax.media.j3d.WakeupOr;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JSlider;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    import javax.vecmath.Color3f;
    import javax.vecmath.Point2f;
    import javax.vecmath.Point3d;
    import javax.vecmath.Point3f;
    import javax.vecmath.Quat4f;
    import javax.vecmath.Vector3d;
    import javax.vecmath.Vector3f;
    import javax.vecmath.Vector4f;
    import com.sun.j3d.audioengines.javasound.JavaSoundMixer;
    import com.sun.j3d.loaders.Scene;
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.behaviors.interpolators.RotPosScaleTCBSplinePathInterpolator;
    import com.sun.j3d.utils.behaviors.interpolators.TCBKeyFrame;
    import com.sun.j3d.utils.geometry.Primitive;
    import com.sun.j3d.utils.geometry.Sphere;
    import com.sun.j3d.utils.image.TextureLoader;
    * This example uses a Spline Interpolator to animate a fly-over the city of
    * Boston. The city is rendered using satellite images with a Level of Detail
    * behavior. The scene includes a number of moving helicopters, each with an
    * associated sound.
    public class SplineInterpolatorTest extends Java3dApplet {
      // size of the 3D window - enlage on powerful systems
      private static int m_kWidth = 200;
      private static int m_kHeight = 200;
      // a shared appearance for the buildings we create
      private Appearance m_BuildingAppearance = null;
      // the size of the high resolution "world".
      // the world is centered at 0,0,0 and extends
      // to +- LAND_WIDTH in the x direction and
      //+- LAND_LENGTH in the z direction.
      // These dimensions are loosely based on pixel
      // coordinates from the texture images
      private static final float LAND_WIDTH = 180;
      private static final float LAND_LENGTH = 180;
      // the satellite images used as textures have
      // been manually edited so that the water in the
      // images corresponds to the following RGB values.
      // this allows the application to avoid creating
      // buildings in the water!
      private static final float WATER_COLOR_RED = 0;
      private static final float WATER_COLOR_GREEN = 57;
      private static final float WATER_COLOR_BLUE = 123;
      public SplineInterpolatorTest() {
        initJava3d();
      // scale eveything so we can use pixel coordinates
      protected double getScale() {
        return 0.1;
      protected int getCanvas3dWidth(Canvas3D c3d) {
        return m_kWidth;
      protected int getCanvas3dHeight(Canvas3D c3d) {
        return m_kHeight;
      protected Bounds createApplicationBounds() {
        m_ApplicationBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),
            10.0);
        return m_ApplicationBounds;
      // we want a texture mapped background of a sky
      protected Background createBackground() {
        // add the sky backdrop
        Background back = new Background();
        back.setApplicationBounds(getApplicationBounds());
        BranchGroup bgGeometry = new BranchGroup();
        // create an appearance and assign the texture image
        Appearance app = new Appearance();
        Texture tex = new TextureLoader("sky.gif", this).getTexture();
        app.setTexture(tex);
        Sphere sphere = new Sphere(1.0f, Primitive.GENERATE_TEXTURE_COORDS
            | Primitive.GENERATE_NORMALS_INWARD, app);
        bgGeometry.addChild(sphere);
        back.setGeometry(bgGeometry);
        return back;
      // this controls how close to a helicopter we can
      // be and still hear it. If the helicopters sound
      // scheduling bounds intersect our ViewPlatformActivationRadius
      // the sound of the helicopter is potentially audible.
      protected float getViewPlatformActivationRadius() {
        return 20;
      // creates the objects within our world
      protected BranchGroup createSceneBranchGroup() {
        BranchGroup objRoot = super.createSceneBranchGroup();
        // create a root TG in case we need to scale the scene
        TransformGroup objTrans = new TransformGroup();
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        Transform3D t3d = new Transform3D();
        objTrans.setTransform(t3d);
        Group hiResGroup = createLodLand(objTrans);
        createBuildings(objTrans);
        createHelicopters(objTrans);
        // connect
        objRoot.addChild(objTrans);
        return objRoot;
      // we create 2 TransformGroups above the ViewPlatform:
      // the first merely applies a scale, while the second
      // has a RotPosScaleTCBSplinePathInterpolator attached
      // so that the viewer of the scene is animated along
      // a spline curve.
      public TransformGroup[] getViewTransformGroupArray() {
        TransformGroup[] tgArray = new TransformGroup[2];
        tgArray[0] = new TransformGroup();
        tgArray[1] = new TransformGroup();
        Transform3D t3d = new Transform3D();
        t3d.setScale(getScale());
        t3d.invert();
        tgArray[0].setTransform(t3d);
        // create an Alpha object for the Interpolator
        Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE
            | Alpha.DECREASING_ENABLE, 0, 0, 25000, 4000, 100, 20000, 5000,
            50);
        // ensure the Interpolator can access the TG
        tgArray[1].setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        try {
          // create the Interpolator and load the keyframes from disk
          RotPosScaleTCBSplinePathInterpolator splineInterpolator = Utils
              .createSplinePathInterpolator(new UiAlpha(alpha),
                  tgArray[1], new Transform3D(), new URL(
                      getWorkingDirectory(),
                      "rotate_viewer_spline.xls"));
          // set the scheduling bounds and attach to the scenegraph
          splineInterpolator.setSchedulingBounds(getApplicationBounds());
          tgArray[1].addChild(splineInterpolator);
        } catch (Exception e) {
          System.err.println(e.toString());
        return tgArray;
      // overidden so that the example can use audio
      protected AudioDevice createAudioDevice(PhysicalEnvironment pe) {
        return new JavaSoundMixer(pe);
      // creates a Switch group that contains two versions
      // of the world - the first is a high resolution version,
      // the second if a lower resolution version.
      public Group createLodLand(Group g) {
        Switch switchNode = new Switch();
        switchNode.setCapability(Switch.ALLOW_SWITCH_WRITE);
        Group hiResGroup = createLand(switchNode);
        createEnvirons(switchNode);
        // create a DistanceLOD that will select the child of
        // the Switch node based on distance. Here we are selecting
        // child 0 (high res) if we are closer than 180 units to
        // 0,0,0 and child 1 (low res) otherwise.
        float[] distanceArray = { 180 };
        DistanceLOD distanceLod = new DistanceLOD(distanceArray);
        distanceLod.setSchedulingBounds(getApplicationBounds());
        distanceLod.addSwitch(switchNode);
        g.addChild(distanceLod);
        g.addChild(switchNode);
        return hiResGroup;
      // creates a high resolution representation of the world.
      // a single texture mapped square and a larger (water colored)
      // square to act as a horizon.
      public Group createLand(Group g) {
        Land land = new Land(this, g, ComplexObject.GEOMETRY
            | ComplexObject.TEXTURE);
        Group hiResGroup = land.createObject(new Appearance(), new Vector3d(),
            new Vector3d(LAND_WIDTH, 1, LAND_LENGTH), "boston.gif", null,
            null);
        Appearance app = new Appearance();
        app.setColoringAttributes(new ColoringAttributes(
            WATER_COLOR_RED / 255f, WATER_COLOR_GREEN / 255f,
            WATER_COLOR_BLUE / 255f, ColoringAttributes.FASTEST));
        Land base = new Land(this, hiResGroup, ComplexObject.GEOMETRY);
        base.createObject(app, new Vector3d(0, -5, 0), new Vector3d(
            4 * LAND_WIDTH, 1, 4 * LAND_LENGTH), null, null, null);
        return hiResGroup;
      // creates a low resolution version of the world and
      // applies the low resolution satellite image
      public Group createEnvirons(Group g) {
        Land environs = new Land(this, g, ComplexObject.GEOMETRY
            | ComplexObject.TEXTURE);
        return environs.createObject(new Appearance(), new Vector3d(),
            new Vector3d(2 * LAND_WIDTH, 1, 2 * LAND_LENGTH),
            "environs.gif", null, null);
      // returns true if the given x,z location in the world
      // corresponds to water in the satellite image
      protected boolean isLocationWater(BufferedImage image, float posX,
          float posZ) {
        Color color = null;
        float imageWidth = image.getWidth();
        float imageHeight = image.getHeight();
        // range from 0 to 1
        float nPixelX = (posX + LAND_WIDTH) / (2 * LAND_WIDTH);
        float nPixelY = (posZ + LAND_LENGTH) / (2 * LAND_LENGTH);
        // rescale
        nPixelX *= imageWidth;
        nPixelY *= imageHeight;
        if (nPixelX >= 0 && nPixelX < imageWidth && nPixelY >= 0
            && nPixelY < imageHeight) {
          color = new Color(image.getRGB((int) nPixelX, (int) nPixelY));
          return (color.getBlue() >= WATER_COLOR_BLUE
              && color.getGreen() <= WATER_COLOR_GREEN && color.getRed() <= WATER_COLOR_RED);
        return false;
      // creates up to 120 building objects - ensures that
      // buildings are not positioned over water.
      public Group createBuildings(Group g) {
        m_BuildingAppearance = new Appearance();
        BranchGroup bg = new BranchGroup();
        Texture tex = new TextureLoader("boston.gif", this).getTexture();
        BufferedImage image = ((ImageComponent2D) tex.getImage(0)).getImage();
        final int nMaxBuildings = 120;
        for (int n = 0; n < nMaxBuildings; n++) {
          Cuboid building = new Cuboid(this, bg, ComplexObject.GEOMETRY
              | ComplexObject.TEXTURE);
          float posX = (int) Utils.getRandomNumber(0, LAND_WIDTH);
          float posZ = (int) Utils.getRandomNumber(0, LAND_LENGTH);
          if (isLocationWater(image, posX, posZ) == false) {
            building.createObject(m_BuildingAppearance, new Vector3d(posX,
                0, posZ), new Vector3d(Utils.getRandomNumber(3, 2),
                Utils.getRandomNumber(8, 7), Utils
                    .getRandomNumber(3, 2)), "house.gif", null,
                null);
        g.addChild(bg);
        return bg;
      // creates three helicopters
      public void createHelicopters(Group g) {
        for (int n = 0; n < 3; n++)
          createHelicopter(g);
      // edit the positions of the clipping
      // planes so we don't clip on the front
      // plane prematurely
      protected double getBackClipDistance() {
        return 50.0;
      protected double getFrontClipDistance() {
        return 0.1;
      // creates a single helicopter object
      public Group createHelicopter(Group g) {
        BranchGroup bg = new BranchGroup();
        Helicopter heli = new Helicopter(this, bg, ComplexObject.GEOMETRY
            | ComplexObject.SOUND);
        heli.createObject(new Appearance(), new Vector3d(Utils.getRandomNumber(
            0, LAND_WIDTH), Utils.getRandomNumber(15, 5), Utils
            .getRandomNumber(0, LAND_LENGTH)), new Vector3d(10, 10, 10),
            null, "heli.wav", null);
        g.addChild(bg);
        return bg;
      public static void main(String[] args) {
        SplineInterpolatorTest splineInterpolatorTest = new SplineInterpolatorTest();
        splineInterpolatorTest.saveCommandLineArguments(args);
        new MainFrame(splineInterpolatorTest, m_kWidth, m_kHeight);
    * Copyright (C) 2001 Daniel Selman
    * First distributed with the book "Java 3D Programming" by Daniel Selman and
    * published by Manning Publications. http://manning.com/selman
    * This program is free software; you can redistribute it and/or modify it under
    * the terms of the GNU General Public License as published by the Free Software
    * Foundation, version 2.
    * This program is distributed in the hope that it will be useful, but WITHOUT
    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    * details.
    * The license can be found on the WWW at: http://www.fsf.org/copyleft/gpl.html
    * Or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite
    * 330, Boston, MA 02111-1307, USA.
    * Authors can be contacted at: Daniel Selman: [email protected]
    * If you make changes you think others would like, please contact one of the
    * authors or someone at the www.j3d.org web site.
    * Java3dApplet
    * Base class for defining a Java 3D applet. Contains some useful methods for
    * defining views and scenegraphs etc.
    * @author Daniel Selman
    * @version 1.0
    abstract class Java3dApplet extends Applet {
      public static int m_kWidth = 300;
      public static int m_kHeight = 300;
      protected String[] m_szCommandLineArray = null;
      protected VirtualUniverse m_Universe = null;
      protected BranchGroup m_SceneBranchGroup = null;
      protected Bounds m_ApplicationBounds = null;
      //  protected com.tornadolabs.j3dtree.Java3dTree m_Java3dTree = null;
      public Java3dApplet() {
      public boolean isApplet() {
        try {
          System.getProperty("user.dir");
          System.out.println("Running as Application.");
          return false;
        } catch (Exception e) {
        System.out.println("Running as Applet.");
        return true;
      public URL getWorkingDirectory() throws java.net.MalformedURLException {
        URL url = null;
        try {
          File file = new File(System.getProperty("user.dir"));
          System.out.println("Running as Application:");
          System.out.println("   " + file.toURL());
          return file.toURL();
        } catch (Exception e) {
        System.out.println("Running as Applet:");
        System.out.println("   " + getCodeBase());
        return getCodeBase();
      public VirtualUniverse getVirtualUniverse() {
        return m_Universe;
      //public com.tornadolabs.j3dtree.Java3dTree getJ3dTree() {
      //return m_Java3dTree;
      public Locale getFirstLocale() {
        java.util.Enumeration e = m_Universe.getAllLocales();
        if (e.hasMoreElements() != false)
          return (Locale) e.nextElement();
        return null;
      protected Bounds getApplicationBounds() {
        if (m_ApplicationBounds == null)
          m_ApplicationBounds = createApplicationBounds();
        return m_ApplicationBounds;
      protected Bounds createApplicationBounds() {
        m_ApplicationBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),
            100.0);
        return m_ApplicationBounds;
      protected Background createBackground() {
        Background back = new Background(new Color3f(0.9f, 0.9f, 0.9f));
        back.setApplicationBounds(createApplicationBounds());
        return back;
      public void initJava3d() {
        //  m_Java3dTree = new com.tornadolabs.j3dtree.Java3dTree();
        m_Universe = createVirtualUniverse();
        Locale locale = createLocale(m_Universe);
        BranchGroup sceneBranchGroup = createSceneBranchGroup();
        ViewPlatform vp = createViewPlatform();
        BranchGroup viewBranchGroup = createViewBranchGroup(
            getViewTransformGroupArray(), vp);
        createView(vp);
        Background background = createBackground();
        if (background != null)
          sceneBranchGroup.addChild(background);
        //    m_Java3dTree.recursiveApplyCapability(sceneBranchGroup);
        //  m_Java3dTree.recursiveApplyCapability(viewBranchGroup);
        locale.addBranchGraph(sceneBranchGroup);
        addViewBranchGroup(locale, viewBranchGroup);
        onDoneInit();
      protected void onDoneInit() {
        //  m_Java3dTree.updateNodes(m_Universe);
      protected double getScale() {
        return 1.0;
      public TransformGroup[] getViewTransformGroupArray() {
        TransformGroup[] tgArray = new TransformGroup[1];
        tgArray[0] = new TransformGroup();
        // move the camera BACK a little...
        // note that we have to invert the matrix as
        // we are moving the viewer
        Transform3D t3d = new Transform3D();
        t3d.setScale(getScale());
        t3d.setTranslation(new Vector3d(0.0, 0.0, -20.0));
        t3d.invert();
        tgArray[0].setTransform(t3d);
        return tgArray;
      protected void addViewBranchGroup(Locale locale, BranchGroup bg) {
        locale.addBranchGraph(bg);
      protected Locale createLocale(VirtualUniverse u) {
        return new Locale(u);
      protected BranchGroup createSceneBranchGroup() {
        m_SceneBranchGroup = new BranchGroup();
        return m_SceneBranchGroup;
      protected View createView(ViewPlatform vp) {
        View view = new View();
        PhysicalBody pb = createPhysicalBody();
        PhysicalEnvironment pe = createPhysicalEnvironment();
        AudioDevice audioDevice = createAudioDevice(pe);
        if (audioDevice != null) {
          pe.setAudioDevice(audioDevice);
          audioDevice.initialize();
        view.setPhysicalEnvironment(pe);
        view.setPhysicalBody(pb);
        if (vp != null)
          view.attachViewPlatform(vp);
        view.setBackClipDistance(getBackClipDistance());
        view.setFrontClipDistance(getFrontClipDistance());
        Canvas3D c3d = createCanvas3D();
        view.addCanvas3D(c3d);
        addCanvas3D(c3d);
        return view;
      protected PhysicalBody createPhysicalBody() {
        return new PhysicalBody();
      protected AudioDevice createAudioDevice(PhysicalEnvironment pe) {
        JavaSoundMixer javaSoundMixer = new JavaSoundMixer(pe);
        if (javaSoundMixer == null)
          System.out.println("create of audiodevice failed");
        return javaSoundMixer;
      protected PhysicalEnvironment createPhysicalEnvironment() {
        return new PhysicalEnvironment();
      protected float getViewPlatformActivationRadius() {
        return 100;
      protected ViewPlatform createViewPlatform() {
        ViewPlatform vp = new ViewPlatform();
        vp.setViewAttachPolicy(View.RELATIVE_TO_FIELD_OF_VIEW);
        vp.setActivationRadius(getViewPlatformActivationRadius());
        return vp;
      protected Canvas3D createCanvas3D() {
        GraphicsConfigTemplate3D gc3D = new GraphicsConfigTemplate3D();
        gc3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
        GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getScreenDevices();
        Canvas3D c3d = new Canvas3D(gd[0].getBestConfiguration(gc3D));
        c3d.setSize(getCanvas3dWidth(c3d), getCanvas3dHeight(c3d));
        return c3d;
      protected int getCanvas3dWidth(Canvas3D c3d) {
        return m_kWidth;
      protected int getCanvas3dHeight(Canvas3D c3d) {
        return m_kHeight;
      protected double getBackClipDistance() {
        return 100.0;
      protected double getFrontClipDistance() {
        return 1.0;
      protected BranchGroup createViewBranchGroup(TransformGroup[] tgArray,
          ViewPlatform vp) {
        BranchGroup vpBranchGroup = new BranchGroup();
        if (tgArray != null && tgArray.length > 0) {
          Group parentGroup = vpBranchGroup;
          TransformGroup curTg = null;
          for (int n = 0; n < tgArray.length; n++) {
            curTg = tgArray[n];
            parentGroup.addChild(curTg);
            parentGroup = curTg;
          tgArray[tgArray.length - 1].addChild(vp);
        } else
          vpBranchGroup.addChild(vp);
        return vpBranchGroup;
      protected void addCanvas3D(Canvas3D c3d) {
        setLayout(new BorderLayout());
        add(c3d, BorderLayout.CENTER);
        doLayout();
      protected VirtualUniverse createVirtualUniverse() {
        return new VirtualUniverse();
      protected void saveCommandLineArguments(String[] szArgs) {
        m_szCommandLineArray = szArgs;
      protected String[] getCommandLineArguments() {
        return m_szCommandLineArray;
    * Utils
    * @author Daniel Selman
    * @version 1.0
    class Utils {
      // convert an angular rotation about an axis to a Quaternion
      static Quat4f createQuaternionFromAxisAndAngle(Vector3d axis, double angle) {
        double sin_a = Math.sin(angle / 2);
        double cos_a = Math.cos(angle / 2);
        // use a vector so we can call normalize
        Vector4f q = new Vector4f();
        q.x = (float) (axis.x * sin_a);
        q.y = (float) (axis.y * sin_a);
        q.z = (float) (axis.z * sin_a);
        q.w = (float) cos_a;
        // It is necessary to normalise the quaternion
        // in case any values are very close to zero.
        q.normalize();
        // convert to a Quat4f and return
        return new Quat4f(q);
      // convert three rotations about the Euler axes to a Quaternion
      static Quat4f createQuaternionFromEuler(double angleX, double angleY,
          double angleZ) {
        // simply call createQuaternionFromAxisAndAngle
        // for each axis and multiply the results
        Quat4f qx = createQuaternionFromAxisAndAngle(new Vector3d(1, 0, 0),
            angleX);
        Quat4f qy = createQuaternionFromAxisAndAngle(new Vector3d(0, 1, 0),
            angleY);
        Quat4f qz = createQuaternionFromAxisAndAngle(new Vector3d(0, 0, 1),
            angleZ);
        // qx = qx * qy
        qx.mul(qy);
        // qx = qx * qz
        qx.mul(qz);
        return qx;
      static public double getRandomNumber(double basis, double random) {
        return basis + ((float) Math.random() * random * 2f) - (random);
      static public double getRandomNumber(double basis, double random,
          double scale) {
        double value = basis + ((float) Math.random() * random * 2f) - (random);
        return value * scale;
      static public StringBuffer readFile(URL urlFile) {
        // allocate a temporary buffer to store the input file
        StringBuffer szBufferData = new StringBuffer();
        Vector keyFramesVector = new Vector();
        try {
          InputStream inputStream = urlFile.openStream();
          int nChar = 0;
          // read the entire file into the StringBuffer
          while (true) {
            nChar = inputStream.read();
            // if we have not hit the end of file
            // add the character to the StringBuffer
            if (nChar != -1)
              szBufferData.append((char) nChar);
            else
              // EOF
              break;
          inputStream.close();
        } catch (Exception e) {
          System.err.println(e.toString());
          return null;
        return szBufferData;
      static public RotPosScaleTCBSplinePathInterpolator createSplinePathInterpolator(
          Alpha alpha, TransformGroup tg, Transform3D axis, URL urlKeyframes) {
        TCBKeyFrame[] keyFrames = readKeyFrames(urlKeyframes);
        if (keyFrames != null)
          return new RotPosScaleTCBSplinePathInterpolator(alpha, tg, axis,
              keyFrames);
        return null;
      static public TCBKeyFrame[] readKeyFrames(URL urlKeyframes) {
        StringBuffer szBufferData = readFile(urlKeyframes);
        if (szBufferData == null)
          return null;
        Vector keyFramesVector = new Vector();
        // create a tokenizer to tokenize the input file at whitespace
        java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(
            szBufferData.toString());
        // each keyframe is defined as follows
        // - knot (0 >= k <= 1)
        // - position (x,y,z)
        // - rotation (rx,ry,rz)
        // - scale (x,y,z)
        // - tension (-1 >= t <= 1)
        // - continuity (-1 >= c <= 1)
        // - bias (-1 >= b <= 1)
        // - linear (int - 0 or 1)
        while (true) {
          try {
            float knot = Float.parseFloat(tokenizer.nextToken());
            float posX = Float.parseFloat(tokenizer.nextToken());
            float posY = Float.parseFloat(tokenizer.nextToken());
            float posZ = Float.parseFloat(tokenizer.nextToken());
            float rotX = Float.parseFloat(tokenizer.nextToken());
            float rotY = Float.parseFloat(tokenizer.nextToken());
            float rotZ = Float.parseFloat(tokenizer.nextToken());
            float scaleX = Float.parseFloat(tokenizer.nextToken());
            float scaleY = Float.parseFloat(tokenizer.nextToken());
            float scaleZ = Float.parseFloat(tokenizer.nextToken());
            float tension = Float.parseFloat(tokenizer.nextToken());
            float continuity = Float.parseFloat(tokenizer.nextToken());
            float bias = Float.parseFloat(tokenizer.nextToken());
            int linear = Integer.parseInt(tokenizer.nextToken());
            TCBKeyFrame keyframe = new TCBKeyFrame(knot, linear,
                new Point3f(posX, posY, posZ),
                createQuaternionFromEuler(rotX, rotY, rotZ),
                new Point3f(scaleX, scaleY, scaleZ), tension,
                continuity, bias);
            keyFramesVector.add(keyframe);
          } catch (Exception e) {
            break;
        // create the return structure and populate
        TCBKeyFrame[] keysReturn = new TCBKeyFrame[keyFramesVector.size()];
        for (int n = 0; n < keysReturn.length; n++)
          keysReturn[n] = (TCBKeyFrame) keyFramesVector.get(n);
        // return the array
        return keysReturn;
    //this class defines an Alpha class that returns a random
    //value every N milliseconds.
    class UiAlpha extends Alpha implements ChangeListener {
      protected Alpha m_Alpha = null;
      protected float m_AlphaValue = 0.5f;
      JButton m_Button = null;
      boolean m_bAuto = true;
      public UiAlpha(Alpha alpha) {
        m_Alpha = alpha;
        Frame frame = new Frame("Alpha Control Panel");
        JPanel panel = new JPanel();
        frame.add(panel);
        addUiToPanel(panel);
        frame.pack();
        frame.setSize(new Dimension(400, 80));
        frame.validate();
        frame.setVisible(true);
      protected void addUiToPanel(JPanel panel) {
        JSlider slider = new JSlider();
        slider.addChangeListener(this);
        panel.add(slider);
        m_Button = new JButton("Auto");
        m_Button.addChangeListener(this);
        panel.add(m_Button);
      public void stateChanged(ChangeEvent e) {
        if (e.getSource() instanceof JSlider) {
          m_AlphaValue = ((JSlider) e.getSource()).getValue() / 100.0f;
          m_bAuto = false;
        } else {
          m_bAuto = true;
      // core method override
      // returns the Alpha value for a given time
      public float value(long time) {
        if (m_bAuto == true)
          return m_Alpha.value(time);
        return m_AlphaValue;
    class Land extends ComplexObject {
      public static final float WIDTH = 1.0f;
      public static final float LENGTH = 1.0f;
      public static final float HEIGHT = 0.0f;
      public Land(Component comp, Group g, int nFlags) {
        super(comp, g, nFlags);
      protected Group createGeometryGroup(Appearance app, Vector3d position,
          Vector3d scale, String szTextureFile, String szSoundFile) {
        int nFlags = GeometryArray.COORDINATES | GeometryArray.NORMALS;
        if ((m_nFlags & TEXTURE) == TEXTURE)
          nFlags |= Geom                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    If this is not your document class, since button1 is not created within the class, there is nothing provided to reference it as an external object.  You need to pass in a reference to it.

  • Error while doing Bulk Collect to a table type

    I'm using a Table type to accumulate resultset from a loop and finally return the records in the table type as a ref cursor to the front end.
    But when I'm using Bult collect to insert into the table type object it keeps throwing an error
    'PLS-00597: expression 'TAB_CALENDAR_AVAIL_RESULTSET' in the INTO list is of wrong type'. Can someone help me to let me know what could be the reason for this error. I'm not able to proceed further, please help.
    Here is the code.
    CREATE OR REPLACE PACKAGE hotel
    AS
    TYPE calendar_cursor IS REF CURSOR;
    TYPE type_calendar_avail is RECORD(
    HOTEL_ID AVAILABILITY_CALENDAR.hotel_id%TYPE,--varchar2(4), --AVAILABILITY_CALENDAR.hotel_id%TYPE,
    AVAIL_DATE AVAILABILITY_CALENDAR.AVAIL_DATE%TYPE ,
    TOTAL_COUNT number
    TYPE type_calendar_avail_resultset IS TABLE OF type_calendar_avail;
    tab_calendar_avail_resultset type_calendar_avail_resultset ; -- declare variable of type type_calendar_avail_resultset
    PROCEDURE sp_get_calendar_results (
    sallhotelswithavaildate VARCHAR2,
    ilengthofstay NUMBER,
    sorcowner VARCHAR2,
    all_unittypes VARCHAR2, --DBMS_SQL.VARCHAR2S
    calendar_resultset OUT calendar_cursor
         -- tab_calendar_avail_resultset out type_calendar_avail_resultset
    PROCEDURE sp_get_calendar_results (
    sallhotelswithavaildate VARCHAR2,
    ilengthofstay NUMBER,
    -- ivariant NUMBER,
    sorcowner VARCHAR2,
    all_unittypes VARCHAR2, --DBMS_SQL.VARCHAR2S
    calendar_resultset OUT calendar_cursor
    AS
    sbuf VARCHAR2 (200);
    sepr VARCHAR2 (1);
    shotelwithdate VARCHAR2 (200);
    shotelid VARCHAR2 (10);
    savaildate VARCHAR2 (8);
    sactualavaildate VARCHAR2 (8);
    pos NUMBER;
    istart NUMBER;
    sstartdate VARCHAR2 (8);
    senddate VARCHAR2 (8);
    squery VARCHAR2 (32767) := '';
    sunittypecond VARCHAR2 (500) := '';
    sunitdesccond VARCHAR2 (500) := '';
    v_unit_cond a_unit_cond;
    tempunitcond VARCHAR2 (50) := '';
    BEGIN
    istart := 1;
    LOOP
    tempunitcond := hotel.stringtokenizer (all_unittypes, istart, '|');
    IF tempunitcond IS NOT NULL
    THEN
    v_unit_cond (istart) := tempunitcond;
    istart := istart + 1;
    END IF;
    EXIT WHEN tempunitcond IS NULL;
    END LOOP;
    sunitdesccond := hotel.get_unit_description_cond (v_unit_cond);
    DBMS_OUTPUT.put_line ('unit description : ' || sunitdesccond);
    sbuf := sallhotelswithavaildate;
    sepr := '|';
    istart := 1;
    LOOP
    shotelwithdate := hotel.stringtokenizer (sbuf, istart, sepr);
    EXIT WHEN shotelwithdate IS NULL;
    shotelid :=
    SUBSTR (shotelwithdate, 1, INSTR (shotelwithdate, ',') - 1);
    savaildate :=
    SUBSTR (shotelwithdate, INSTR (shotelwithdate, ',') + 1);
    squery :=
    ' SELECT MIN (ad.avail_date) '
    || ' FROM wvo_fonres.fpavail_daily ad'
    || ' WHERE ad.hotel_id = '
    || shotelid
    || ' AND ad.days_left >= '
    || ilengthofstay
    || ' AND ad.avail_date >= '
    || savaildate;
    IF UPPER (sorcowner) = 'N'
    THEN
    squery :=
    squery
    || ' AND ad.ORC_TYPE != ''R'' and ad.ORC_TYPE != ''P'' and ad.ORC_TYPE != ''E'' ';
    END IF;
    squery := squery || ' AND ( ' || sunitdesccond || ') ';
    EXECUTE IMMEDIATE squery
    INTO sactualavaildate;
    DBMS_OUTPUT.put_line ('Actual available Date: ' || sactualavaildate);
    hotel.sp_get_startdate_enddate (sactualavaildate,
    --ivariant,
    sstartdate,
    senddate
    sunittypecond := hotel.get_unittype_cond (v_unit_cond, sorcowner);
    -- execute immediate
    squery :=
    'select HOTEL_ID, AVAIL_DATE, ' || sunittypecond || ' AS TOTAL_COUNT '
    || ' FROM AVAILABILITY_CALENDAR A '
    || 'WHERE '
    || 'AVAIL_DATE >= '''
    || sstartdate
    || ''' '
    || 'AND '
    || 'AVAIL_DATE <= '''
    || senddate
    || ''' '
    ||'AND '
    || 'A.HOTEL_ID IN ('
    || shotelid
    || ') '
    || 'AND ('
    || sunittypecond
    || '> 0) '
    || -- where total available count of unit type is greater than 0
    ' ORDER BY AVAIL_DATE'; --order clause
         open calendar_resultset for squery;
         fetch calendar_resultset BULK COLLECT INTO tab_calendar_avail_resultset;
    istart := istart + 1;
    END LOOP;
    COMMIT;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line
    (SQLERRM (SQLCODE));
    RAISE;
    END sp_get_calendar_results;
    END hotel;
    /

    1. put tags [co[/b][b]de] and [co[/b][b]de] around your code, so it's readable
    B. what does "hotel.get_unittype_cond (v_unit_cond, sorcowner)" actually retun?
    and third, try this for the array declaration:
    tab_calendar_avail_resultset type_calendar_avail_resultset := type_calendar_avail_resultset ; () ;

Maybe you are looking for

  • Employer Quarterly Tax Returns (India)

    we are facing 1 very crucial issue which we need to finish it up by today EOD. otherwise Company will be penalized every day some amount. plz advise. at the erliest. Employer Quarterly Tax Returns (India) for 2012-13 FI for Quarter1 we are doing, tot

  • Encountered error r6034, runtime error, window error 1114 for itune 11.1.4 update.

    encountered error r6034, runtime error, window error 1114 for itune 11.1.4 update. Same error msgs for when I tried to uninstall and reinstall as suggested. pls advise if you have another solution to it... thx

  • Cross System Lock

    Hi I have an requirement,  when a contract edited in CRM system the same contract should not be available for edidting in R/3 system. can any one guide me how to implement this functionality in R/3 thanks & regards.

  • Weird behaviour for ant task source2wsdd

    I got the following when I've tried to run source2wsdd at linux server with weblogic 8.1 SP3: [source2wsdd] Loading source file /home/klai/dev/LSF/ws_ejb/src/lsf/webservices/WebServicesDemoLocal.java... [source2wsdd] Constructing Javadoc information.

  • Weird scamming issue

    Hi to all I am an free skype user many years ago. I never bought credits and i never set a paypal account. Today it came at my skype home the following notification Spoiler (Highlight to read)  We've delivered your order . More info Less info .Thanks