System.out.println ....syntax error?

Hi,
I am workin on my first java program here...and althought my classes compile just fine I can't manage to get what I want to appear on the screen on Button action....
Clicking on cost should trigger the appearance of the total cost...but nothing happens.
Can you have a look and tell me where I went wrong please?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
public class Booking extends Applet implements ItemListener,ActionListener
String[][] c = { {"French Language","250","130","70"}, {"Painting","270","140","70"}, {"Yoga","250","130","70"} };
Courses courses_list = new Courses(c);
Choice ChoiceCourse;
Choice ChoicePeople;
Checkbox cb1, cb2, cb3;
boolean fulltime = false;
boolean parttime = false;
boolean concessions = false;
Button b1;
int c1;
int p1;
int price;
public void init()
  add(new Label("Courses available for booking : "));
  ChoiceCourse = new Choice();
  add(ChoiceCourse);
//the following populates the ChoiceCourse dropDown Menu with the Courses'Titles
  int i=0;
  while (i<c.length)
    ChoiceCourse.addItem(courses_list.getTitle(i));
    i++;
  ChoiceCourse.addItemListener(this);
  add(new Label("Number of participants for the course selected : "));
  ChoicePeople = new Choice();
  add(ChoicePeople);
//the following populates the ChoicePeople dropDown Menu with "numbers" from 1 to 10
  int j=1;
  while (j<11)
    ChoicePeople.addItem(new Integer(j).toString());
    j++;
  ChoicePeople.addItemListener(this);
  cb1 = new Checkbox ("Full-Time");
  add(cb1);
  cb2 = new Checkbox ("Part-Time");
  add (cb2);
  cb3 = new Checkbox ("Concessions");
  add (cb3);
  b1 = new Button ("Cost");
  add (b1);
  b1.addActionListener(this);
  public void itemStateChanged(ItemEvent e)
   if (e.getSource() == ChoiceCourse)
     String c2 = (String) e.getItem();  // When ChoiceCourse is modified
     if (c2 == "French Language")
       int c1 = 0;
     if (c2 == "Painting")
       int c1 = 1;
     else
       int c1 = 2;
   if (e.getSource() == ChoicePeople)
     String p2 = (String) e.getItem();  // When ChoicePeople is modified
     int p1=Integer.parseInt(p2);       // converts the String into an integer
  public void actionPerformed(ActionEvent e)
    if ( e.getActionCommand() == "Cost" )
      fulltime = cb1.getState();
      parttime = cb2.getState();
      concessions = cb3.getState();
      if (fulltime == true)
        int price = 1;
      if (parttime == true)
        int price = 2;
      else
        int price = 3;
      int mode =  Integer.parseInt(c[c1][price]);  
      System.out.println("total cost of your selection is: �" + courses_list.getCost(p1,mode));
}

Thanks for the guidance and the explanations. I've improved my code according to your recommendations (1, 2 &3) and it compiles just fine.
However, the println still doesn't work...but there is improvement:
When I run my applet using the AppletViewer at the very end I get a log of what happened...and it's now showing:
"D:\JBuilder8\jdk1.4\bin\appletviewer.exe Booking.html
total cost of your selection is: �0"
Which means that the println is being called but is not printing where it should be (on my screen)....the other problem is that it is obviously not properly calculating the total cost since it shouldn't be �0.
Here is my new (improved) code, and below is the code for the Courses class (which does some of the calculation):
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
public class Booking extends Applet implements ItemListener,ActionListener
String[][] c = { {"French Language","250","130","70"}, {"Painting","270","140","70"}, {"Yoga","250","130","70"} };
Courses courses_list = new Courses(c);
Choice ChoiceCourse;
Choice ChoicePeople;
Checkbox cb1, cb2, cb3;
boolean fulltime = false;
boolean parttime = false;
boolean concessions = false;
Button b1;
int c1;
int p1;
int price;
public void init()
  add(new Label("Courses available for booking : "));
  ChoiceCourse = new Choice();
  add(ChoiceCourse);
//the following populates the ChoiceCourse dropDown Menu with the Courses'Titles
  int i=0;
  while (i<c.length)
    ChoiceCourse.addItem(courses_list.getTitle(i));
    i++;
  ChoiceCourse.addItemListener(this);
  add(new Label("Number of participants for the course selected : "));
  ChoicePeople = new Choice();
  add(ChoicePeople);
//the following populates the ChoicePeople dropDown Menu with "numbers" from 1 to 10
  int j=1;
  while (j<11)
    ChoicePeople.addItem(new Integer(j).toString());
    j++;
  ChoicePeople.addItemListener(this);
  cb1 = new Checkbox ("Full-Time");
  add(cb1);
  cb2 = new Checkbox ("Part-Time");
  add (cb2);
  cb3 = new Checkbox ("Concessions");
  add (cb3);
  b1 = new Button ("Cost");
  add (b1);
  b1.addActionListener(this);
  public void itemStateChanged(ItemEvent e)
   if (e.getSource().equals (ChoiceCourse)) //should this be == or .equals? it doesn't work either way but compiles
     String c2 = (String) e.getItem();  // When ChoiceCourse is modified
     if (c2.equals ("French Language"))
       c1 = 0;
     if (c2.equals ("Painting"))
       c1 = 1;
     else
       c1 = 2;
   if (e.getSource().equals (ChoicePeople)) //should this be == or .equals?it doesn't work either way but compiles
     String p2 = (String) e.getItem();  // When ChoicePeople is modified
     p1=Integer.parseInt(p2);       // converts the String into an integer
  public void actionPerformed(ActionEvent e)
    if ( e.getActionCommand().equals ("Cost") )
      fulltime = cb1.getState();
      parttime = cb2.getState();
      concessions = cb3.getState();
      if (fulltime)
        price = 1;
      if (parttime)
        price = 2;
      else
        price = 3;
      int mode =  Integer.parseInt(c[c1][price]);  
      System.out.println("total cost of your selection is: �" + courses_list.getCost(p1,mode));
class Courses
import java.util.*;
public class Courses
private String[][] Listing = new String[3][4]; //create array 3 rows * 4 columns
Courses(String[][] c)
   this.Listing=c;
int i;
int j;
int p;
int price;
int people;
int cost;
String t;
String p1;
String getTitle(int i)  //return Course Title
   t=Listing[0];
return t;
int getPrice(int i, int j) //return Price (Full-Time, Part-Time, Concessions)
p1=Listing[i][j];
p=Integer.parseInt(p1);
return p;
int getCost(int pe, int pp)
pe=price;
pp=people;
cost=pe*pp;
return cost;

Similar Messages

  • I have jave 7 I'm trying underscore option in String.   as String strNum = "1000_000";System.out.println("..abc..."  Integer.parseInt(strNum)); but getting error. could you please help in this?

    Hi,
    There is a new feature added in java 7 on integer, called as underscore '_" and it is working fine
    if it is a normal int variable  but if it is coming with String jvm throw the error.
    if  any one of you have java8 installed on your PC can you check this is working on that version.
    int a = 1000_000;   
    String strNum = "1000_000";
    // System.out.println("..abc..."+ Integer.parseInt(strNum));
    System.out.println("a..."+a);
    Thank you,
    Shailesh.

    what is your actual question here?
    bye
    TPD

  • Can't figure out why syntax errors are coming up

    Here is a simple Binary search type program, but instead of cutting the array in half, it uses interpolation to search the array. Here is the code, but I am getting syntax errors, I will post them below the code:
    public class BinIntSearch {
         private int interlope;
         private int low;
         private int high;
         private int[10] array1 = {6,500,600,700,800,900,1000,2000,3000,4000};
         public BinIntSearch() {//Start of Constructor
    interlope = 0;
         low = 0;
    high = 0;
    public int Search(int[] values, int target) {
    low = 0;
    high = 9;
    while(low < high)
    if(array1[low] == target)
         return low;
         else
    if(array1[high] == target)
    return high;
         interlope = (target - array1[low])/(array1[high] - array1[low]);
         interlope = low + (high - low) * interlope;
         if(interlope <= low)
         high--;
         else
         low = interlope;
    }//end of while loop
    System.out.println("Target not found");
    return -1;
    }//end of method
    public static void main(String args[])
    BinIntSearch binSearch = new BinIntSearch();
    binSearch.Search(array1,600);     
    }//end of class     
    here is the errors:
    C:\BinIntSearch\BinIntSearch.java:6: ']' expected
         private int[10] array1 = {6,500,600,700,800,900,1000,2000,3000,4000};
    ^
    C:\BinIntSearch\BinIntSearch.java:6: <identifier> expected
         private int[10] array1 = {6,500,600,700,800,900,1000,2000,3000,4000};
    ^
    C:\BinIntSearch\BinIntSearch.java:27: cannot resolve symbol
    symbol : variable array1
    location: class BinIntSearch
    if(array1[low] == target)
    ^
    C:\BinIntSearch\BinIntSearch.java:30: cannot resolve symbol
    symbol : variable array1
    location: class BinIntSearch
    if(array1[high] == target)
    ^
    C:\BinIntSearch\BinIntSearch.java:33: cannot resolve symbol
    symbol : variable array1
    location: class BinIntSearch
         interlope = (target - array1[low])/(array1[high] - array1[low]);
    ^
    C:\BinIntSearch\BinIntSearch.java:33: cannot resolve symbol
    symbol : variable array1
    location: class BinIntSearch
         interlope = (target - array1[low])/(array1[high] - array1[low]);
    ^
    C:\BinIntSearch\BinIntSearch.java:33: cannot resolve symbol
    symbol : variable array1
    location: class BinIntSearch
         interlope = (target - array1[low])/(array1[high] - array1[low]);
    ^
    C:\BinIntSearch\BinIntSearch.java:49: cannot resolve symbol
    symbol : variable array1
    location: class BinIntSearch
    binSearch.Search(array1,600);     
    ^
    8 errors
    Process completed.

    Thanks you guys, I made the change and learned something new and it worked. I made a refinement to the program, so i can initialize an array with consecutive numbers instead of typing in 10 I can have like 1000 or 1000000, I am getting 1 error. I can't figure this one out also. Also what is the meanding of static?
    here is the code and below it is the one error
    public class BinIntSearch {
    private int interlope;
    private int low;
    private int high;
    private int i;
    private int array1[10000];
    public BinIntSearch() {//Start of Constructor
    for(i = 0; i < 10000; i++)
    array1[i] = i;
    interlope = 0;
    low = 0;
    high = 0;
    Search(array1,500);
    public int Search(int[] values, int target) {
    low = 0;
    high = 9;
    while(low < high)
    if(array1[low] == target)
         System.out.println("Target Found");
    return low;
    if(array1[high] == target)
    System.out.println("Target Found");
    return high;
    interlope = (target - array1[low])/(array1[high] - array1[low]);
    interlope = low + (high - low) * interlope;
    if(interlope <= low)
    high--;
    else
    low = interlope;
    }//end of while loop
    System.out.println("Target not found");
    return -1;
    }//end of method
    public static void main(String args[])
    BinIntSearch binSearch = new BinIntSearch();
    }//end of class
    C:\BinIntSearch\BinIntSearch.java:8: ']' expected
    private int array1[10000];
    ^
    1 error
    Process completed.

  • Is there a way to force System.out.println to run when called

    I working on my first threaded program and having a hard time debugging. I've used System.out.println to let me know what's going on but due (I assume) to the nature of threads the output is not sequential. Is there a way to force println to execute immediatly so that they show up in the order they were called?
    Thanks --- Mike

    mjs1138 wrote:
    endasil, Thanks for the reply. I'm currenlty running the program from within the NetBeans IDE. It is the output displayed by in NetBeans "output" that I'm looking at.
    --- MikeI don't use Netbeans, but I would guess that it too pipes Standard Out and Standard Error to the same console. You didn't address my comment. Are you printing to System.err as well? This happens implicitly if you use Exception.printStackTrace(), for example.

  • Where to see the System.out.println statements on soa server.

    Hi,
    I have generated some proxy classes in my jdeveloper. And I have deployed that project to the admin server on my soa_domain.
    Now my java files have some System.out.println statements. I want to see those values.
    Can anyone please let me know where I can see those statements on server.
    What s the file name where i can see.
    do i have to enable some debigging on the server. if yes then for what level i need to enable the log at what level.
    Thanks
    Anoop

    Hi,
    System.out.println is not really a good way to debug in weblogic... If you didn't configure where the stdout will go those messages can end up going nowhere...
    I suggest you use one of these...
    This will go to the soa*diagnostic logs... for example DOMAIN_HOME/servers/soa_server1/soa_server1-diagnostic.log...
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import oracle.fabric.logging.LogFormatter;
        private static final Logger soa_logger = Logger.getLogger("oracle.soa.Logger");
        static {
            LogFormatter.configFormatter(soa_logger);
            soa_logger.log(Level.INFO, message);
            soa_logger.log(Level.INFO, message, t);or
    This will go to the server logs... for example DOMAIN_HOME/servers/soa_server1/soa_server1.log...
    import weblogic.logging.NonCatalogLogger;
        private static NonCatalogLogger weblogic_logger = new NonCatalogLogger("SomeMeaningfulNameHere");
            weblogic_logger.notice(message);
            weblogic_logger.notice(message, t);Usually info and notice will go to the logs by default, you can try with higher levels (error,warning) as well or you can tweek the server debug level to use lower levels...
    Cheers,
    Vlad

  • Print System.out.println messages into logs of Weblogic Application Server

    Hi,
    I use Weblogic Application Server 10.3.6 on Windows 7. The Enterprise Application (J2EE) is deployed into the 'AdminServer' of Weblogic. For debugging purpose, I have added a few System.out.println statements.
    I am unable to see the print messages on any of log files available in path 'user_projects > domains > base_domain > servers > AdminServer > logs'. However, I can see them on the 'command' prompt which was used to start the server. How can I get them into one of the log files? What am I missing?
    I tried reading other threads on the forum and as per them 'System.out.println' gets logged onto *.out logs which I am unable to find. Only base_domain.log, AdminServer.log, access.log are available in the location.
    More Specifics:
    Configuration on WLS console 'Home > Servers > AdminServer > Logging'
    Log file name: logs/AdminServer.log
    Min. Severity to log: Notice (tried with Debug as well)
    Advanced Options:
    Logging Implementation: JDK
    Redirect stdout logging enabled: False (tried both options)
    Log file Severity Level: Notice (tried with Debug as well)
    Standard Out Severity Level: Notice (tried with Debug as well)
    Thanks

    Paul,
    I just found this on google:
    'Generally, developers put a lot of System.out.println statements in their code to perform application debugging. Normally, all standard outputs and error outputs are routed to the console where the OC4J server is started. If you want to capture the standard output and error outputs to files for logging/debugging purposes, then you can use the -out and -err options while starting up the Oc4J server to specify which files to use.'.
    http://www.onjava.com/pub/a/onjava/2002/01/16/oracle.html?page=2

  • System.out.println crashes wireless toolkit

    I'm using system.out.println calls to create debugging commands to test my application. They mostly work but if I try to print out a lot at once the wireless toolkit crashes.
    This is all on my computer, not on any mobile device.
    The error I get is:
    Exception in thread "Child process stdout copier" java.lang.ClassCastException: sun.java2d.NullSurfaceData cannot be cast to sun.java2d.d3d.D3DSurfaceData
         at sun.java2d.d3d.D3DRenderer.copyArea(D3DRenderer.java:55)
         at sun.java2d.d3d.D3DSurfaceData.copyArea(D3DSurfaceData.java:638)
         at sun.java2d.SunGraphics2D.doCopyArea(SunGraphics2D.java:1986)
         at sun.java2d.SunGraphics2D.copyArea(SunGraphics2D.java:1968)
         at javax.swing.BufferStrategyPaintManager.copyArea(BufferStrategyPaintManager.java:315)
         at javax.swing.RepaintManager.copyArea(RepaintManager.java:1228)
         at javax.swing.JViewport.blitDoubleBuffered(JViewport.java:1604)
         at javax.swing.JViewport.windowBlitPaint(JViewport.java:1573)
         at javax.swing.JViewport.setViewPosition(JViewport.java:1118)
         at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.vsbStateChanged(BasicScrollPaneUI.java:1027)
         at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(BasicScrollPaneUI.java:1016)
         at javax.swing.DefaultBoundedRangeModel.fireStateChanged(DefaultBoundedRangeModel.java:348)
         at javax.swing.DefaultBoundedRangeModel.setRangeProperties(DefaultBoundedRangeModel.java:285)
         at javax.swing.DefaultBoundedRangeModel.setValue(DefaultBoundedRangeModel.java:151)
         at javax.swing.JScrollBar.setValue(JScrollBar.java:446)
         at com.sun.kvem.toolbar.MainWindow$ConsoleStream.write(Unknown Source)
         at java.io.PrintStream.write(PrintStream.java:430)
         at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
         at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
         at com.sun.kvem.environment.StreamCopier.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)Am I doing something wrong or is this a bug in the toolkit?
    Once I get this exception the whole toolkit becomes unresponsive and I have to close it and re-open.

    mydreamgirl, welcome to the forum. Please don't post in threads that are long dead and don't hijack another poster's thread. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
    I'm locking this thread now.
    db

  • Linux System.out.println()

    I am porting some JSP's from Windows to SUSE Linux. These JSP's call functions that are embedded in JAVA classes, which in turn output error messages with System.out.println() to the console. It appears that in Linux, the bash Konsole doesn't print these errors, so they are invisible.
    I suppose that if I wrote JSP's in the future, errors could be printed in the browser, but I would really like to be able to see my errors in bash or which ever shell. Any help would be appreciated.

    If you ever intend to use more than one webserver, I would suggest you look towards something like JMS. Messages can be sent to the queue from which you can pick them up and deal with them as necessary in your own time, be that real-time or delayed.
    If you think you will never need more than one, why not write a little log file reader? Remember though that the catalina.out file will grow and grow unless you stop Tomcat, rename the old file and restart Tomcat.

  • Sustitution of System.out.println in Graphical mode

    Dear Sirs:
    I am changing my applications to graphical mode. I would like to know what is the command that substitutes System.out.println in graphical mode. Thanks in advance

    I am not sure exactly what you mean when you say you are changing your apps to graphical mode,
    I assume you will be using Swing?
    If you will be using a gui in the place of a command prompt program, you may need to completely redesign your app (I'm not sure I can help you with that).
    In a Java applet, and application, you can still use System.out.println. It will print to the console while your app runs. I use it pretty often for simple debugging (Although I use JBuilder and the option for the execution Log, if you are in windows and expect the size of the errors to be large an don't have something like this, you may want to run the output into a file using the IO package).
    Hope this helps you,
    Dan Hughes
    Dear Sirs:
    I am changing my applications to graphical mode. I
    would like to know what is the command that
    substitutes System.out.println in graphical mode.
    Thanks in advance

  • System.out.println in EJB

    Hi I have given System.out.println in my EJB object. But I am not able to see the output in my console. But when I give printStackTrace in my JSP(from where I can EJB)....it is displaying the exception....
    So my question is Can we give System.out... in EJB?. Should we set any property to see the output of System.out...in the console?.

    Here is my code
    From UserManager I call the EJB
    public boolean validateSignOn(String strUserName,String strPassword) throws ProdSchedException{
    try{
    UserMgrHome home = (UserMgrHome)getEJBHome("UserMgr",UserMgrHome.class);
    UserMgr userMgr = home.create();
    return userMgr.validateSignOn(strUserName,strPassword);
    catch(RemoteException rex){
    ServerLog.log(rex.getMessage(),ServerLog.ERROR);
    throw new ProdSchedException(rex,"Server Failed");
    catch(CreateException cex){
    ServerLog.log(cex.getMessage(),ServerLog.ERROR);
    throw new ProdSchedException(cex,"Create Exception");
    This is my EJB code
    import javax.ejb.*;
    import java.rmi.RemoteException;
    import java.util.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.w3c.dom.*;
    import java.io.*;
    * User Manager Session Bean
    public class UserMgrEJB implements SessionBean {
    SessionContext cntx;
    public boolean validateSignOn(String strUserName,String strPassword) throws ProdSchedException{     
    UserDAO dao = new UserDAO();
         System.out.println("Inside EJB");
    boolean bValidUser = dao.validateUser(strUserName,strPassword);
    if(!bValidUser){
    throw new ProdSchedException("Invalid User");
    return bValidUser;
    //Bean methods
    public void ejbCreate(){
         System.out.println("Inside EJB Create");
    public void ejbRemove(){
    public void ejbActivate(){
         System.out.println("Inside EJB Activate");
    public void ejbPassivate(){
    public void setSessionContext(SessionContext cntx){
    this.cntx = cntx;
    This is mu UserDAO code
    public class UserDAO extends DAO{
    public boolean validateUser(String userName,String password) throws ProdSchedException{
    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet result = null;
         System.out.println("Inside validateUser in DAO");
    try{
              boolean bIsValidUser = true;
         String selectStatement = "SELECT SYSDATE from DUAL";
         conn = getConnection();
    stmt = conn.prepareStatement(selectStatement);
    result = stmt.executeQuery();
    while(result.next()){
    bIsValidUser = true;
    return bIsValidUser;
    catch(SQLException sqex){
    ServerLog.log(sqex.getMessage(),ServerLog.ERROR);
    throw new ProdSchedException(sqex,sqex.getMessage());
         finally{
    try{
    close(conn,stmt,result);
    catch(ProdSchedException slex){
                   ServerLog.log(slex.getMessage(),ServerLog.ERROR);
    throw slex;
    } // end class
    And the error I get in the console is this(since I have given printStackTrace in my JSP)
    ProdSchedException: SQL Error
    at UserDAO.validateUser(UserDAO.java:
    44)
    at UserMgrEJB.validateSignOn(
    UserMgrEJB.java:26)
    at UserMgrEJB_p3hctp_EOImpl.v
    alidateSignOn(UserMgrEJB_p3hctp_EOImpl.java:46)
    at UserManager.validateSignOn(User
    Manager.java:20)
    at jsp_servlet._public.__login._jspService(__login.java:123)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
    (ServletStubImpl.java:1094)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:437)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:319)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
    n.run(WebAppServletContext.java:5626)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
    eManager.java:685)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
    rvletContext.java:3213)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
    pl.java:2555)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:251)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:219)

  • System.out.println and Network Adapter problem

    Hello,
    I am encountering a 2 strange problems. I have 2 oracle application server instances, one dev and one production.
    The first problem is when I type System.out.println in the JSP's i am able to see the output in both \opmn\logs\oc4jinstance. But the System.out.println in the java classes or bean show up only in development logs but not in production box.
    Is there a setting I am missing here?
    The second problem is on our development machine the application works fine, but as soon as we deploy the application on production I encounter:
    could not open new connection: Io exception: The Network Adapter could not establish the connection
    I have a class called DBUtils, which uses a 3rd party library to get connections from the connection pool as below. Using JSP I call the getConnection(). On my dev Oracle Application Server Instance it works fine, but on production I get the error. Can it be there is a setting that I am missing on the production box?
    When I use a JSP and connect to the database without using the DBUtil class. I can connect to the database fine. Also using the DBUtil class with production oracle IP address on the development machine lets me connect with no problem, but production machine does not let me.
    public class DBUtils {
    static ConnectionPoolBean pool;
    static {
    System.out.println("DBUtils() - before connection pool bean");
    pool = new ConnectionPoolBean();
    pool.setDriverClassName("oracle.jdbc.driver.OracleDriver");
    pool.setdbURL("jdbc:oracle:thin:@IPADDRESS:PORT:SID");
    pool.setUser("USERNAME");
    pool.setPassword("PASSWORD");
    pool.setInitialConnections(1);
    pool.setIncrement(1);
    pool.setSoftMaxConnections(40);
    public static Connection getConnection() throws SQLException {
    System.out.println("Getting Oracle Connection");
    return pool.getConnection();
    public static void returnConnection(Connection conn) throws SQLException {
    System.out.println("Returning Connection");
    pool.returnConnection(conn);
    Thanks for your help in advance.

    Hi
    System.out.println is a method of PrintStream in IO which is used to print the output on console in java progs.Here in jsp ,the o/p is printed on server's console window.But out.println is totally different as, out is implicit object derived from JspWriter and is used sly to PrinWriter 's object is used in servlets.It's work is to write upon Browser.
    System.out.println() is normally used in jsp for debugging purposes only.
    Ashish

  • System.out.println logged to ?

    I am using Oracle 9ias 9.0.3 java edition.
    I have deployed a war file successfully using EM.
    i HAVE System.out.println statements in my servlets. I was unable to find any documents which tell me where these statements will be logged?
    Any one help me.

    Go to server properties page of OEM and edit OC4J options under Command Line Options. You will have to specify the OC4J option -out filename to capture the System.out messages. You can also specify the option -err filename to capture all the errors.
    check out http://technet.oracle.com/tech/java/oc4j/htdocs/oc4j-logging-debugging-technote.html

  • Lost System.out.println statements.

    Hi
    I have few system.out.println in my jsp which i am using in my JSP provider channel. but when I look at the portal server's /var/opt/SUNWam/debug/desktop.debug file, none are there.. I looked at the web server's access and error logs too, but it is not there also.. can somebody tell me how do it get those ?? do we have any other mechanism to put debug logs ?

    By default the binary which web server runs is uxwdog which eats up System.out.println output. If you want to see the System.out.println then you need to change the product binary from the start script of the portal server instance.
    - Go to <portal-install-dir>/SUNWam/servers/https-<instance-name> and open the start script
    - Change the PRODUCT_BIN=uxwdog to PRODUCT_BIN=ns-httpd , save the file
    - Run the script ./start to start the portal server
    Note : with ns-httpd ON the server will not leave that shell, and in the same window/shell you will be able to see all your System.out.println statements. To close the server you have to kill the server process with "kill -9 pids" command
    Alternate way is to use api inside your application or jsp:
    <%@page import="com.sun.portal.providers.jsp.JSPProvider, com.sun.portal.providers.*, com.sun.portal.providers.containers.*, com.sun.portal.providers.context.*" %>
    <% JSPProvider p=(JSPProvider)pageContext.getAttribute("JSPProvider");
    ProviderContext pc = p.getProviderContext(); %>
    <%-- after that you can use these lines any where in your jsp --%>
    <%
    pc.debugError("your error msg");
    pc.debugMessage("your msg");
    pc.debugWarning("your warning msg");
    %>
    The perticular mgs will be shwon in /var/opt/SUNWam/debug/desktop.debug file as per your "debugLevel" parameter setting in /etc/opt/SUNWps/desktop/desktopconfig.properties file. By default the debugLevel is set to error so only pc.debugError("error msg") will be shown.
    Sanjeev

  • System.out.println() problem

    When I use operator + for concatenate the following Strings
    md.getDriverName() + md.getDriverVersion()
    as follow in a try block:
    try {
    con = DriverManager.getConnection(sourceURL,user,pass);
    md = con.getMetaData();
    System.out.println(md.getDriverName().+md.getDriverVersion());
    when I have tried run java -cp postgresql.jar errors message appers :
    Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: conx
    at java.lang.VMClassLoader.transformException(java.lang.Class, java.lang.Throwable) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
    at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)
    at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
    Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:postgresql.jar,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
    at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)
    But when I have used netBeans IDE v 4.0 it works fine.
    Might somebody help me for solve it.

    Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in
    gnu.gcj.runtime.SystemClassLoader{urls=[file:postgresql.jar,file:./],
    As I noted in your other post, your computer is configured to use gnu.gcj, not Sun's Java - and it appears that gcj doesn't have the StringBuilder class; it was added to Sun Java in Java 5.

  • Synchronized use of System.out.println()

    So I am again at the point of part of my program running ahead of itself out of the call stack and ruining the sequence or order of printing.
    I read that System.out.println() is synchronized so how may it be used to wait() until notified to continue and not ruin the output?

    jverd wrote:
    Always Learning wrote:
    YES SIR EJP! SIR! I thank you for the assistance because using only System.out and synchronizing worked beautifully.You said you're not using multiple threads. If this is true, then there's no reason to synchronize anything. The output will appear on System.out in exactly the order you send it there.
    Nos if only I could figure out dependencies to make it work with out and err.You have to stop and think about it for a minute. You know that when you call println() on either one of those two streams, the output may be buffered an not necessarily go immediately to the console. From that you can reason that if you call out.println() first, and then err.println(), that you could end up with err's buffer getting flushed first, and the output appearing on the console in a different order than that in which your code executed the calls.
    You are of course not surprised by this, given that you know that out and err are completely independent and just happen to end up at the same destination in this particular case.
    So, as a first guess, you might reasonably think that, since buffering is obviously the culprit here, calling flush() on each stream after each print() or println() call should eliminate the problem. In a multithreaded environment, this wouldn't be sufficient, of course, but it's a logical approach to try here.
    Another tidbit to make note of is that the System class has setOut() and setErr() calls. Since you're looking at out and err in the same console, you presumably don't care about the distinction between them (which makes me wonder why you're using them both in the first place, instead of just using one). If you're just going to mush them together into the same console anyway, then you can use setOut() or setErr() to make them the same stream, and things will be ordered as you expect.Very interesting Jverd and I think there may yet be life in what I would like to do. I did not know or was not immediately aware of these things. I will give it a try.
    To answer your question, I am using them both because, like logging, they are distinct in the Eclipse console (black for out and red for err). With your patch I just tried that distinction has faded but the output is sequenced the same so I do appreciate you noting this. Learn something new in Java each time I am doing a project. I considered using logging and putting errors in a window but I am not sure if I should do that; just not enough experience with it.
    Edited by: Always Learning on Oct 23, 2011 9:28 AM

Maybe you are looking for

  • Copy and paste - Restricted KF - Left panel

    Hello All, This is quite a silly question, in BI7 I cannot copy and paste a restricted KF in the left panel. Options are there but it's not working. Is this another bug in BI7 ? Thanks C.

  • E-Recruiting :Problem with BUPA_CENTRAL_CHANGE for HRALXSYNC

    Dear Experts, We have a problem with the function module BUPA_CENTRAL_CHANGE while executing the report HRALXSYNC & trying to repair the object P. Please note that the sample implementations for the relevant BADIs are activated. Relevant entries are

  • File lock during exec() use

    Hi, thanks for your attention. I'm having the following problem: (using Java 6 and Windows XP) I want to open an image tools from my java program, using an image file already existing, during my java program execution. But when I try to save the edit

  • Where are languages file for switch series 200?

    i can't find languages file for series 200 switch...where are????

  • Audigy 2 ZS Boot Prob

    Hi folks, i've switched my pc on some days ago and it didn't boot at all. After some testing of parts in other systems i've found the problem: the power supply was damaged! I've bought a new one and everything is running fine except my Audigy 2 ZS ca