Help regarding Stacks and Queues.!!!!!!Please....

I have a working program right now..But it lacks some things to be done..It already does the stacks and queues..But still it doesnt print the info on the desired output file outTwo.dat..Both the stacks and queues should be printed on it..Also it has to compute the total commission on categories 1 and 2...and put it again on the outTwo.dat..Any kind hearted people would want to help me here?Here's the assignment detail...Thank YOU!!!!
Q2. Linked List
a.     create a compile AStack class, and a AQueue class similar to the text
b.     provide an application that will:
�     instantiate an AStack object and an AQueue object
�     create a property object for each data line read from the input file assign4.dat
�     push it ti the stack if its is category 1 property; queue if its is category 2; ignore all others
�     print a title called category 1 to an output file called outTwo.dat
�     after printing a few blank lines to outTwo.dat, print a title called category 2 to outTwo.dat
�     traverse the queue and print it to the same output file outTwo.dat
�     print the total commission earned on this category of property to outTwo.dat
Note that for this question you should also print out and submit outTwo.dat. Have Fun!
//This is the program I have done so far....
import java.io.*;
import java.util.StringTokenizer;
public class TestSQ {
     public static void readFileSQ(AStack s, AQueue q)
          try {
FileReader inStream=new FileReader("assign4.dat");
BufferedReader ins= new BufferedReader(inStream);
FileWriter outStream=new FileWriter("outTwo.dat");
PrintWriter outs= new PrintWriter(outStream);
String line;
int category;
double price;
String categoryString;
String priceString;
StringTokenizer st;
while((line=ins.readLine())!=null) {
st=new StringTokenizer(line," ");
if(st.countTokens()==2){
categoryString = st.nextToken();
priceString = st.nextToken();
try{
category = Integer.parseInt(categoryString);
price = Double.parseDouble(priceString);
Property myProperty = new Property(category, price);
myProperty.setCommissionRate();
myProperty.getCommission();
     if(category==1)
s.push(myProperty);
outs.println(s.toString());
if(category==2)
                         q.insert(myProperty);
                         outs.println(q.toString());
}catch(NumberFormatException nfe){
System.out.println("error while parsing Integer: "+categoryString+"/"+priceString);
else
System.out.println("invalid number of elements in line: " +st.countTokens());
catch (IOException e) {
System.out.println("i/o error:"+e.getMessage());
e.printStackTrace();
     public static void showStack(AStack s){
          while(!s.isEmpty()){
               Object line=s.pop();
               System.out.println(line);
public static void main(String args[])
     AStack stackOfProperty=new AStack();
     AQueue queueOfProperty=new AQueue();
     readFileSQ(stackOfProperty,queueOfProperty);
     showStack(stackOfProperty);
     System.out.println();
     System.out.println(queueOfProperty.toString());
}

import java.io.*;
import java.util.StringTokenizer;
public class TestSQ {
     public static void readFileSQ(AStack s, AQueue q)
          try {
            FileReader inStream=new FileReader("assign4.dat");
            BufferedReader ins= new BufferedReader(inStream);
            FileWriter outStream=new FileWriter("outTwo.dat");
            PrintWriter outs= new PrintWriter(outStream);
            String line;
            int category;
            double price;
            String categoryString;
            String priceString;
            StringTokenizer st;
             while((line=ins.readLine())!=null) {
                st=new StringTokenizer(line," ");
                if(st.countTokens()==2){
                    categoryString = st.nextToken();
                    priceString = st.nextToken();
                    try{
                        category = Integer.parseInt(categoryString);
                        price = Double.parseDouble(priceString);
                        Property myProperty = new Property(category, price);
                        myProperty.setCommissionRate();
                        myProperty.getCommission();
                            if(category==1)
                        s.push(myProperty);
                      //  outs.println(s.toString());
                        else if(category==2)
                             q.insert(myProperty);
                             outs.println(q.toString());
                    }catch(NumberFormatException nfe){
                        System.out.println("error while parsing Integer: "+categoryString+"/"+priceString);
                else
                    System.out.println("invalid number of elements in line: " +st.countTokens());
            outs.close();
            ins.close();
        catch (IOException e) {
            System.out.println("i/o error:"+e.getMessage());
            e.printStackTrace();
     public static void showStack(AStack s){
          while(!s.isEmpty()){
               Object line=s.pop();
               System.out.println(line);
    public static void main(String args[])
         AStack stackOfProperty=new AStack();
         AQueue queueOfProperty=new AQueue();
         readFileSQ(stackOfProperty,queueOfProperty);
         showStack(stackOfProperty);
         System.out.println();
         System.out.println(queueOfProperty.toString());
   }//This is the updated version of my program..Now the ouput file works now, but then it shows different ouput..Thats only for the queue.I dont know about the stack..Tnx for looking...

Similar Messages

  • Stacks and Queues

    Hello, I am new to Java and am working out an assignment. I need to manipulate some stacks and queues in various ways.
    I need to reverse a stack in three different ways:
    1. using two additional stacks.
    2. using one additional queue.
    3. using one additional stack and some additional non-array variables.
    I think I have ways to do 1 and 2 but I'm a bit confused about 3.
    For 1, I would pop the the elements off of the full stack A, and push them onto B. Then pop them from B and push them to C. Then pop them from C and push them to A, thus reversing the order.
    For 2, simply pop the elements from the stack and enqueue them in the queue. Then dequeue them and push them back to the stack.
    For 3, not really sure where to start or how? I could think of how to do it with an array but I'm drawing a blank on this. I don't want anyone to write the code for me just maybe point me in the right direction?
    The assignment then carries on to sorting in ascending order using a stack and then just using non-array variables. I feel like if I can figure out number 3 above the rest will be along similar lines.
    Any help is greatly appreciated.

    The restrictions might be nudging towards a constant-storage algorithm. In which case, try the following.
    You can move any element to the top of the stack using a stack and non-array variables. Take the 4th element for example:
    Pop 3 elements from the stack and push onto the other.
    Pop the next element and store in a variable.
    Pop the 3 elements from the second stack and push back on the first.
    Push the value from the variable onto the first stack.
    This can be used for reversing and sorting the stack.

  • Stack and queue problem

    hi i am trying to change infix expression to postfix and also the opposite, like
    ((a+b)*(a-c*d)/(b+d*e)) to ab+acb*-bde+/
    using stack and queue
    I am so confuse

    Hello,
    See this URL :
    http://www24.brinkster.com/premshree/perl
    You will find the algorithms here.
    Here is a Perl version :
    #     Script:          infix-postfix.pl
    #     Author:          Premshree Pillai
    #     Description:     Using this script you can :
    #               - Convert an Infix expression to Postfix
    #               - Convert a Postfix expression to Infix
    #               - Evaluate a Postfix expression
    #               - Evaluate an Infix expression
    #     Web:          http://www.qiksearch.com
    #     Created:     23/09/02 (dd/mm/yy)
    #     � 2002 Premshree Pillai. All rights reserved.
    sub isOperand
         ($who)=@_;
         if((!isOperator($who)) && ($who ne "(") && ($who ne ")"))
              return 1;
         else
              return;
    sub isOperator
         ($who)=@_;
         if(($who eq "+") || ($who eq "-") || ($who eq "*") || ($who eq "/") || ($who eq "^"))
              return 1;
         else
              return;
    sub topStack
         (@arr)=@_;
         my $arr_len=@arr;
         return($arr[$arr_len-1]);
    sub isEmpty
         (@arr)=@_;
         my $arr_len=@arr;
         if(($arr_len)==0)
              return 1;
         else
              return;
    sub prcd
         ($who)=@_;
         my $retVal;
         if($who eq "^")
              $retVal="5";
         elsif(($who eq "*") || ($who eq "/"))
              $retVal="4";
         elsif(($who eq "+") || ($who eq "-"))
              $retVal="3";
         elsif($who eq "(")
              $retVal="2";
         else
              $retVal="1";
         return($retVal);
    sub genArr
         ($who)=@_;
         my @whoArr;
         for($i=0; $i<length($who); $i++)
              $whoArr[$i]=substr($who,$i,1);
         return(@whoArr);
    sub InfixToPostfix
         ($infixStr)=@_;
         my @infixArr=genArr($infixStr);
         my @postfixArr;
         my @stackArr;
         my $postfixPtr=0;
         for($i=0; $i<length($infixStr); $i++)
              if(isOperand($infixArr[$i]))
                   $postfixArr[$postfixPtr]=$infixArr[$i];
                   $postfixPtr++;
              if(isOperator($infixArr[$i]))
                   if($infixArr[$i] ne "^")
                        while((!isEmpty(@stackArr)) && (prcd($infixArr[$i])<=prcd(topStack(@stackArr))))
                             $postfixArr[$postfixPtr]=topStack(@stackArr);
                             pop(@stackArr);
                             $postfixPtr++;
                   else
                        while((!isEmpty(@stackArr)) && (prcd($infixArr[$i])<prcd(topStack(@stackArr))))
                             $postfixArr[$postfixPtr]=topStack(@stackArr);
                             pop(@stackArr);
                             $postfixPtr++;
                   push(@stackArr,$infixArr[$i]);
              if($infixArr[$i] eq "(")
                   push(@stackArr,$infixArr[$i])
              if($infixArr[$i] eq ")")
                   while(topStack(@stackArr) ne "(")
                        $postfixArr[$postfixPtr]=pop(@stackArr);
                        $postfixPtr++;
                   pop(@stackArr);
         while(!isEmpty(@stackArr))
              if(topStack(@stackArr) eq "(")
                   pop(@stackArr)
              else
                   $temp=@postfixArr;
                   $postfixArr[$temp]=pop(@stackArr);
         return(@postfixArr);
    sub PostfixToInfix
         ($postfixStr)=@_;
         my @stackArr;
         my @postfixArr=genArr($postfixStr);
         for($i=0; $i<length($postfixStr); $i++)
              if(isOperand($postfixArr[$i]))
                   push(@stackArr,$postfixArr[$i]);
              else
                   $temp=topStack(@stackArr);
                   pop(@stackArr);
                   $pushVal=topStack(@stackArr).$postfixArr[$i].$temp;
                   pop(@stackArr);
                   push(@stackArr,$pushVal);
         return((@stackArr));
    sub PostfixEval
         ($postfixStr)=@_;
         my @stackArr;
         my @postfixArr=genArr($postfixStr);
         for($i=0; $i<length($postfixStr); $i++)
              if(isOperand($postfixArr[$i]))
                   push(@stackArr,$postfixArr[$i]);
              else
                   $temp=topStack(@stackArr);
                   pop(@stackArr);
                   $pushVal=PostfixSubEval(topStack(@stackArr),$temp,$postfixArr[$i]);
                   pop(@stackArr);
                   push(@stackArr,$pushVal);
         return(topStack(@stackArr));
    sub PostfixSubEval
         ($num1,$num2,$sym)=@_;
         my $returnVal;
         if($sym eq "+")
              $returnVal=$num1+$num2;
         if($sym eq "-")
              $returnVal=$num1-$num2;
         if($sym eq "*")
              $returnVal=$num1*$num2;
         if($sym eq "/")
              $returnVal=$num1/$num2;
         if($sym eq "^")
              $returnVal=$num1**$num2;
         return($returnVal);
    sub joinArr
         (@who)=@_;
         my $who_len=@who;
         my $retVal;
         for($i=0; $i<$who_len; $i++)
              $retVal.=$who[$i];
         return $retVal;
    sub evalInfix
         ($exp)=@_;
         return PostfixEval(joinArr(InfixToPostfix($exp)));
    sub init
         my $def_exit="\n\tThank you for using this Program!\n\tFor more scripts visit http://www.qiksearch.com\n";
         printf "\n\tInfix - Postfix\n";
         printf "\n\tMenu";
         printf "\n\t(0) Convert an Infix Expression to Postfix Expression";
         printf "\n\t(1) Convert a Postfix Expression to Infix Expression";
         printf "\n\t(2) Evaluate a Postifx Expression";
         printf "\n\t(3) Evaluate an Infix Expression";
         printf "\n\t(4) Exit this Program";
         printf "\n\t(5) About this Program\n";
         printf "\n\tWhat do you want to do? (0/1/2/3/4/5) ";
         $get=<STDIN>;
         chomp $get;
         if(!(($get eq "0") || ($get eq "1") || ($get eq "2") || ($get eq "3") || ($get eq "4") || ($get eq "5")))
              printf "\n\t'$get' is an illegal character.\n\tYou must enter 0/1/2/3/4/5.";
         if(($get ne "4") && ($get ne "5") && (($get eq "0") || ($get eq "1") || ($get eq "2") || ($get eq "3")))
              printf "\n\tEnter String : ";
              $getStr=<STDIN>;
              chomp $getStr;
         if($get eq "0")
              printf "\tPostfix String : ";
              print InfixToPostfix($getStr);
         if($get eq "1")
              printf "\tInfix String : ";
              print PostfixToInfix($getStr);
         if($get eq "2")
              printf "\tPostfix Eval : ";
              print PostfixEval($getStr);
         if($get eq "3")
              printf "\tExpression Eval : ";
              print evalInfix($getStr);
         if($get eq "4")
              printf $def_exit;
              exit 0;
         if($get eq "5")
              printf "\n\t======================================================";
              printf "\n\t\tInfix-Postfix Script (written in Perl)";
              printf "\n\t\t(C) 2002 Premshree Pillai";
              printf "\n\t\tWeb : http://www.qiksearch.com";
              printf "\n\t======================================================\n";
              printf "\n\tUsing this program, you can : ";
              printf "\n\t- Convert an Infix Expression to Postfix Expression.";
              printf "\n\t Eg : 1+(2*3)^2 converts to 123*2^+";
              printf "\n\t- Convert a Postfix Expression to Infix Expression.";
              printf "\n\t Eg : 123*+ converts to 1+2*3";
              printf "\n\t- Evaluate a Postfix Expression";
              printf "\n\t Eg : 37+53-2^/ evaluates to 2.5";
              printf "\n\t- Evaluate an Infix Expression";
              printf "\n\t Eg : (5+(4*3-1))/4 evaluates to 4";
              printf "\n\n\tYou can find the algorithms used in this Program at : ";
              printf "\n\t-http://www.qiksearch.com/articles/cs/infix-postfix/index.htm";
              printf "\n\t-http://www.qiksearch.com/articles/cs/postfix-evaluation/index.htm";
              printf "\n\n\tYou can find a JavaScript implementation of 'Infix-Postfix' at : ";
              printf "\n\t-http://www.qiksearch.com/javascripts/infix-postfix.htm";
         printf "\n\n\tDo you want to continue? (y/n) ";
         my $cont=<STDIN>;
         chomp $cont;
         if($cont eq "y")
              init();
         else
              printf $def_exit;
              exit 0;
    init;

  • Help regarding ABAP and ABAP Objects

    Dear all,
    I am very new in abap and abap objects. But i have some expr. in other language..specialy development. Right now i am working for srm module...So i want to move my self into abap object and specialy in workflow...Please provide me help regarding this...along with the starting point for this.
    Best Regards
    Vijay Patil

    hi
    Object Oriented prg
    A programming technique in which solutions reflect real world objects
    What are objects ?
    An object is an instantiation of a class. E.g. If “Animal” is a class, A cat
    can be an object of that class .
    With respect to code, Object refers to a set of services ( methods /
    attributes ) and can contain data
    What are classes ?
    A class defines the properties of an object. A class can be instantiated
    as many number of times
    Advantages of Object Orientated approach
    Easier to understand when the system is complex
    Easy to make changes
    Encapsulation - Can restrict the visibility of the data ( Restrict the access to the data )
    Polymorphism - Identically named methods behave differently in different classes
    Inheritance - You can use an existing class to define a new class
    Polymorphism and inheritance lead to code reuse
    Have a look at these good links for OO ABAP-
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com.
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    check the below links lot of info and examples r there
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    these links
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    Hope this helps
    if it helped, you can acknowledge the same by rewarding
    regards
    ankit

  • Need help Regarding Payroll and OM

    Hi All,
    Can any one of you provide me a configuration documents regarding Payroll and OM ..I need it very badly.Can any of you help me out in this.You can mail to my id
    [email protected].
    Thanks in advance,
    Sandeep

    hi friends
    can u anybody have Payroll(PCR) DOC , please help me andn  send to my mail ID. [email protected]
    Thanks in advance
    Regards,
    Ramesh.n

  • Help with java coding involving stacks and queues.

    I was wondering if anyone can help with tips on what to fill in for the coding.
    My project is to creating a word processor by the process of 2 stacks. The methods are given, but I'm not really sure what goes in them. So I was wonder if anyone can answer this for me, or give tips that would be great thanks.
    Example Code, similar to what were suppose to do, but instead it's CHARACTER stacks rather than String.
    [http://www.cs.jhu.edu/~jason/226/hw3/source/EditableString.java]

    /** Stack of Characters to the left of the cursor; the ones
       * near the top of the stack are closest to the cursor.
      private Stack left;
      /** Stack of Characters to the right of the cursor; the ones
       * near the top of the stack are closest to the cursor.
      private Stack right;Do you know how a stack works?
    No - Google it
    Yes - Continue on with this post
    /** Another constructor.
       * @param left The text to the left of the cursor.
       * @param right The text to the right of the cursor.
      public EditableString(String left, String right) {
        // fill this in
      }Do you know how to read?
    No - How did you answer this question then?
    Yes - Then why can't you read the comments above each method. Is it really that hard to understand?
    Mel

  • Iterative maze generation with a stack and queue

    I searched the forums, and a couple of hits were interesting, particularly http://forum.java.sun.com/thread.jsp?forum=54&thread=174337 (the mazeworks site is very very cool), but they all centered on using a recursive method to create a maze. Well, my recursive maze generation is fine; it seems to me that recursion lends itself quite well to this particular form of abuse, so well in fact that I am having trouble wrapping my head around an iterative approach. :) I need to create a maze iteratively, using a stack if specified by the user, else a queue. I can vaguely see how a stack simulates recursion but conceptualization of the queue in particular is making my hair hurt. So I was just wondering if anyone had any thoughts or pointers that they wouldn't mind explaining to me to help me with this project. Thanks kindly.
    Maduin

    Stacks (i.e. a first in, last out data storage structure) are very, very closely tied to recursive calls - after all, the only reason that the recursion works at all is because the language is placing the current state of the method on a stack before it calls the method again.
    As for using queue's to implement the same type of thing, are you allowed to use a dequeue (double ended queue)? If so, dequeue's are a pretty common way of implementing a stack - they allow you to implement both FILO and FIFO (first in, first out) structures by whether you pull the stored item from the head or tail of the dequeue.
    If you are talking about a FIFO, then that's a different story - let us know!
    - K
    PS - recursion is an odd topic to get your head around - keep working at it! The biggest thing to realize is that all recursive routines must have SOME way to exit them without continuing the recursion. The design of a recursive call, then, is generally easiest to do when implemented by answering the following question: "Under what condition should the recursion stop?", and then building the routine backwards from there.

  • Help regarding socket and postgresql

    hi, i found this error while im generating a report
    for my system, "Aging of Accounts Receivables"
    hope someone might give me a hint to what should i do.
    here's my StackTrace:
    ***Exception:
    org.postgresql.util.PSQLException: The connection attempt failed because Exception: java.net.BindException: Address already in use: connect
    Stack Trace:
    java.net.BindException: Address already in use: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at java.net.Socket.<init>(Socket.java:366)
    at java.net.Socket.<init>(Socket.java:179)
    at org.postgresql.core.PGStream.<init>(PGStream.java:47)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:197)
    at org.postgresql.Driver.connect(Driver.java:139)
    org.postgresql.util.PSQLException: The connection attempt failed because Exception: java.net.BindException: Address already in use: connect
    Stack Trace:
    java.net.BindException: Address already in use: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at java.net.Socket.<init>(Socket.java:366)
    at java.net.Socket.<init>(Socket.java:179)
    at org.postgresql.core.PGStream.<init>(PGStream.java:47)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:197)
    at org.postgresql.Driver.connect(Driver.java:139)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:72)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:55)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:72)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:55)
    at org.postgresql.jdbc3.Jdbc3ConnectionPool.getPooledConnection(Jdbc3ConnectionPool.java:39)
    at org.postgresql.jdbc3.Jdbc3ConnectionPool.getPooledConnection(Jdbc3ConnectionPool.java:39)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getPooledConnection(PoolingDataSource.java:406)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getConnection(PoolingDataSource.java:338)
    at csfwdbillingmodules.dbConnect.<init>(dbConnect.java:73)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.processAccountAR(frmAgingOfAccounts.java:794)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.genDetailedReport(frmAgingOfAccounts.java:1102)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:406)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:400)
    at javax.swing.SwingWorker$1.call(SwingWorker.java:279)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at javax.swing.SwingWorker.run(SwingWorker.java:319)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    End of Stack Trace
    at org.postgresql.jdbc2.optional.PoolingDataSource.getPooledConnection(PoolingDataSource.java:406)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getConnection(PoolingDataSource.java:338)
    at csfwdbillingmodules.dbConnect.<init>(dbConnect.java:73)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.processAccountAR(frmAgingOfAccounts.java:794)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.genDetailedReport(frmAgingOfAccounts.java:1102)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:406)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:400)
    at javax.swing.SwingWorker$1.call(SwingWorker.java:279)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:208)
    at org.postgresql.Driver.connect(Driver.java:139)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:72)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:55)
    at org.postgresql.jdbc3.Jdbc3ConnectionPool.getPooledConnection(Jdbc3ConnectionPool.java:39)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getPooledConnection(PoolingDataSource.java:406)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getConnection(PoolingDataSource.java:338)
    at csfwdbillingmodules.dbConnect.<init>(dbConnect.java:73)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.processAccountAR(frmAgingOfAccounts.java:794)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.genDetailedReport(frmAgingOfAccounts.java:1102)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:406)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:400)
    at javax.swing.SwingWorker$1.call(SwingWorker.java:279)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at javax.swing.SwingWorker.run(SwingWorker.java:319)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    java.lang.NullPointerException
    at csfwdbillingmodules.dbConnect.query(dbConnect.java:96)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.processAccountAR(frmAgingOfAccounts.java:798)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.genDetailedReport(frmAgingOfAccounts.java:1102)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at javax.swing.SwingWorker.run(SwingWorker.java:319)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    End of Stack Trace
    here's my dbConnect.class:
    * dbConnect.java
    * Created on November 14, 2006, 5:06 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    * @author darkoasis
    package csfwdbillingmodules;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.InetAddress;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.net.SocketAddress;
    import java.net.SocketException;
    import java.net.SocketImpl;
    import java.sql.*; // All we need for JDBC
    import javax.naming.NamingException;
    import org.postgresql.jdbc3.Jdbc3PoolingDataSource;
    public class dbConnect
    extends java.lang.Object
    private Socket socket;
    private SocketImpl socketImpl;
    private int refPosition = 0;
    private Jdbc3PoolingDataSource source = new Jdbc3PoolingDataSource();
    private DriverManager drvMgr;
    private Connection db = null; // A connection to the database
    private Statement sql; // Our statement to run queries with
    private ResultSet results; // A result container
    private DatabaseMetaData dbmd; // This is basically info the driver delivers
    // about the DB it just connected to. I use
    // it to get the DB version to confirm the
    // connection in this example.
    /** Creates a new instance of dbConnect */
    public dbConnect()
    try
    this.source.setServerName("10.10.10.10");
    this.source.setDatabaseName("myDB");
    this.source.setUser("xxxx");
    this.source.setPassword("xxxx");
    this.db = this.source.getConnection();
    this.socket = new Socket();
    dbmd = this.db.getMetaData(); //get MetaData to confirm connection
    sql = this.db.createStatement(); //create a statement that we can use later
    catch (Exception ex)
    System.out.println("***Exception:\n"+ex);
    ex.printStackTrace();
    public ResultSet query(String strSQL)
    throws SQLException
    this.results = this.sql.executeQuery(strSQL);
    return this.results;
    public void update(String strSQL)
    throws SQLException
    this.sql.executeUpdate(strSQL);
    public void close()
    throws Exception
    this.db.close();
    this.socket.close();
    this.source.close();
    public boolean isClosed()
    throws SQLException
    return this.db.isClosed();
    i ran into some forums and found this:
    Hi Graham
    I'm making a bit of progress. I found a website that suggested the following
    This is a problem of the used sockets with Windows NT. You can request the active sockets with the command netstat. The problem is a function of:
    MaxUserPort (default 5000)
    KeepAliveTime (default 120)
    it suggested the workaround was connection pooling
    I have run netstat to look at the number of connections when the problem occurs and waited for the timeout to reset the os back to the minimum and on each occasion my report has run
    Does this sound logical?
    If so
    do you have any examples on connection pooling
    it seems that even if i have closed my database connection it still doesn't free my port that was used, that's why i get this error
    i am looking for a way to close my db connection and free its socket or port used at the same time, hope you can help,
    thanks in advance

    Duplicate of this thread, reply there:
    http://forum.java.sun.com/thread.jspa?threadID=5121873&messageID=9426716#9426716

  • Website on data structures such as stacks and queues.

    Hi,
    I'm currently try to read up on data structures such as stacks, queues but don't quite understand how to implement that. Is there any useful links with example that I can read up from?
    Thanks

    Depends what you mean by "implement". If you want to use standard Java classes that are already written, and you want to know which to choose, then
    http://java.sun.com/docs/books/tutorial/collections/
    If you want to write your own, for some obscure reason, then read a book on data structures. Or try to write your own implementation of the Java collection classes.

  • Help with EJB and JNDI, please

    Hello. My name is Santiago, and i am a student from the University of Valladolid, in Spain. I am newcome in the world of EJB, I have done the first EJB from de Sun tutorial (I�m using the Sun Java System Application Server PE 8.2) and now I am trying to improve it in that way: I have the EJB and the client in diferent machines conected.
    I am trying to understand how to use JNDI, but i have not good results :( I have read about using ldap but i dont know if it is apropiated, or if it is installed automaticaly with the sun aplication, or if i have to download and install it... i am not sure about anything :)
    This is my client�s code (part of it)
    Hashtable envirom = new Hashtable();
    envirom.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    envirom.put("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
    envirom.put(Context.PROVIDER_URL,"iiop://Santiago:389");
    envirom.put(Context.PROVIDER_URL,"ldap://192.168.1.101:389");
    envirom.put(Context.SECURITY_AUTHENTICATION,"none");
    InitialContext ctx = new InitialContext(envirom);
    Object objref = ctx.lookup("java:comp/env/ejb/Multiplica");
    When I try to connect in local mode (client and EJB in the same machine) i get something like that:
    javax.naming.CommunicationException: 192.168.1.101:389 [Root exception is java.n
    et.ConnectException: Connection refused: connect]
    at com.sun.jndi.ldap.Connection.<init>(Connection.java:204)
    at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:118)
    at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1578)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2596)
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:283)
    It is even worse when i try it in different machines:
    10-mar-2006... com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImp1<init>
    ADVERTENCIA: "IOP00410201: <COMM_FAILURE> Fallo de conexion: Tipo de socket: IIOP_CLEAR_TEXT;
    name of host: portatil; puerto: 3700"
    org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code:201 completed:No
    Both SSOO are XP and I have disabled Firewalls.
    PLEASE, if you colud help me It would fantastic, because I am in that trouble, i have tryed 1000 solutions but i am not able to understand it.
    Hoping you can help me.
    Santiago.

    This thread is now being followed up in:
    http://swforum.sun.com/jive/thread.jspa?threadID=64092

  • I need some advanced help regarding AE and PPRO workflow

    Hi all.
    I have a problem and require a solution. I am creating a video that has cellphone/IM chat graphics, animated in After Effects. The problem is the layering.
    In PPRO, the layers are as follows on the timeline.
    Top layer: Chat Graphics
    Middle Layer: Adjustment layer with colour grade effects
    Bottom Layer: Footage
    Now the issue I am having is that I need the chat graphics to cast a Gaussian Blur underneath them (the graphics are at 80% opacity) - and I have successfully done this using the AE Adjustment Layer switch, however since the graphics are in AE, and the footage is in Premiere, they blur does not appear. In other words, the graphics in AE are set to blur the layer below itself IN AE, but the footage layer below is IN PPRO.
    So... one might think that the obvious solution is to layer it all in AE, using the Replace with AE Composition option in PPRO. However, this means that the adjustment layer for the grade will affect the chat graphics which need to be consistent.
    Help...

    Just to report back - The Track Matte Key effect worked like a charm.
    Just had to create two extra layers in PPro.
    One duplicate layer of blurred footage. One duplicate layer of graphics to become the matte, on top of the footage layer.
    The effect of Gaussian Blur and Track Matte Key was applied on the footage layer.
    Thanks again Richard

  • Help with erasing and syncing please - what will be erased?

    I have somehow created a 2nd itunes account and my iphone won't sync with the first one. It is syncing with the 2nd one however I cannot add new music - if I try on the 2nd one I get a message asking if I want to erase this iphone and sync with this itunes library.  Below this is a warning that erasing and syncing will replace the contenst of this iphone with the contents of this itunes library.  What exactly will be erased?  If it's just the music and photos then I won't mind - my phone is new and not got much on it.  However I don't want to lose all my apps and contacts information.  I know I can back it all up but I am not very knowledgable about all this - I am new to itunes and iphones just last month!  Any advice gratefully recieved - thank-you! 

    OK so its been a LONG time since messing with this but now I have to get it done. I have tried all this that is stated in this thread and I can do what I am looking for IF I start a new file, draw a few shapes, apply the pathfinder divide.
    However, with this file I am working with I can not figure out why I cant get it to work.
    Again, what i am trying to do is have a LOT of lines crossing over the edges of the templates that are the shapes in my AI file. Think 80's style Eddie Van Halen guitar. They're going to be graphic for my sons motorcycle for his birthday.
    I was trying to simply use the rectangle tool to draw various black and white lines and then somehow cut the overhangs off my templates.
    Very frustrating that I cant figure out what I am doing wrong!! Especially since I am fairly proficient in After Effects, Premiere, and Photoshop. Trying to learn Illustrator though!!
    By the way using CS3
    Thanks for anyone that can help me!!!
    You can download my project file here.
    pages.sbcglobal.net/dntsdad/tylercrf150r.ai

  • Urgent Help Regarding PDF and Word Document Downloading

    Many Thanks Shaik for you humble help. Actually now what I did in the past 3 days,
    I used Oracle Intermedia to store my PDF and Word Documents in the database using Oracle SQL Loader. Then I used PL/SQL Server Pages and Oracle Web Toolkit for the downloading of my documents.
    Now the problem is I saved all my formatted documents in the databse and for retrieval I am using following code in my stored procedure
    * Select BLOB Data
    select blob_data into myblob from mytable where blob_name = name;
    Setup headers which describes the content
    owa_util.mime_header('text/html', FALSE);
    htp.p('Content-Length: ' || dbms_lob.get_length(myblob));
    owa_util.http_header_close;
    Initiate Direct BLOB download
    wpg_docload.download_file(myblob);
    end;
    The structure of the mytable table:
    create table mytable
    doc_id varchar2(128),
    doc_name varchar2(128),
    blob_data blob
    But when it prompt the client to download the file actually it gives the junk file name like 'B104ea56' (which i understand is the address of the blob address). What I want is to show the "SAVE AS" download box with the proper document name which is stored in my field in the following way
    1 SALES.PDF
    2 PLANNING.PDF
    3 MANUAL.DOC
    4 STANDARD.TXT
    If I set the MIME type for the file format than it automatically starts download the file to the client browser, that I do not want, It should ask the user to download with the proper document name.
    Waiting consiously for your help
    Regards

    Presumedly you'd like those documents being accessiable by users as well, so they should be put on a web server, ftp or nfs sharing. You can just add the urls to those documents, or the directory they are in, into robot system as starting points and let robot run to collect them.

  • Need Help Regarding Users and Roles

    Hi,
    I have Created a role with Password authentication and in that role only object privilege (SELECT TABLE) and System Privilige (CREATE SESSION)
    Now I created user name abbasi and add above role to it and make that role as its default role.
    Now when I connect above user from SQL*Plus its Connected.
    I want to know since for there is Password Authentication then why during the session databse server not authenticate for role password.
    Actually I want to know real usage of password autheticated role.
    Regards.
    D.abbasi

    See the following demo
    SQL> conn aman/aman
    Connected.
    SQL> create user test identified by test;
    User created.
    SQL> create role test_role ;
    Role created.
    SQL> grant create session to test_role;
    Grant succeeded.
    SQL> create role dangerous identified by danger;
    Role created.
    SQL> grant drop any table to dangerous;
    Grant succeeded.
    SQL> grant dangerous, test_role to test;
    Grant succeeded.
    SQL> alter user test default role test_role;
    User altered.
    SQL> conn test/test
    Connected.
    SQL> select * from session_roles;
    ROLE
    TEST_ROLE
    SQL> select * from session_privs;
    PRIVILEGE
    CREATE SESSION
    SQL> set role dangerous;
    set role dangerous
    ERROR at line 1:
    ORA-01979: missing or invalid password for role 'DANGEROUS'
    SQL> set role dangerous identified by danger;
    Role set.
    SQL> select * from session_roles;
    ROLE
    DANGEROUS
    SQL> select * from session_privs;
    PRIVILEGE
    DROP ANY TABLEYou should not make the roles haivng the passwords as the default roles. Let them be there but not as the default roles. These roles can be enabled by the end user when he needs that. In my example, I have made a user TEST, two roles, TEST_ROLE, Dangerous. Dangerous is password protected and contains a priv drop any table. I have made TESt_role as the default role for the user and it becomes active. But for the dangerous,I need to supply the paswword. If I don't , I get an error like I have shown inthe example.
    HTH
    Aman....

  • Stack and Queue

    Where do we use them?So far i haven't come across any program which uses them.

    You could use a stack for a calculator application, or a queue for a resource management application.

Maybe you are looking for

  • Problem with Winclone and Windows 7 Bootcamp

    I previously used Winclone to backup and restore onto the windows 7 partition when I had Snow Leopard. Now on Lion, Winclone won't work, and of course my bootcamp was not restored with the upgrade. I've tried partitioning the mac HD into 2 drives, th

  • How do I store images in a jar file to be displayed on a jsp?

    Afternoon all, I have created a java component which accepts some parameters and returns a string. The returned string contains html tags to display a table in a webpage when rendered through a browser. I want to be able to add this component to any

  • DHCP Option Tags are not being applied...

    Hi, About to loose my mind... basically we are working towards a small WYSE Thin Client deployment in our environment.  The WYSE clients require to receive certain DHCP Option Tags to find the WCM server of which they receive their configuration from

  • XI R2 report with dynamic connection

    I am looking for a simple sample *.aspx application (.NET 2.0 prefered) that will take a report name and connection name (as in the repository) and run the report for the current user (All my users are in the AD and single sign on works) There is so

  • Missing edited photos from iPhoto after Force Quit

    I just lost about 50 photos.  I'm using a separate application to edit my photos before transferring them to my iPhoto Library.  A couple hours in to editing I received an error message and had to force quit both iPhoto and my other photo editing app