What's wrong with this simple code?

What's wrong with this simple code? Complier points out that
1. a '{' is expected at line6;
2. Statement expected at the line which PI is declared;
3. Type expected at "System.out.println("Demostrating PI");"
However, I can't figure out them. Please help. Thanks.
Here is the code:
import java.util.*;
public class DebugTwo3
// This class demonstrates some math methods
public static void main(String args[])
          public static final double PI = 3.14159;
          double radius = 2.00;
          double area;
          double roundArea;
          System.out.println("Demonstrating PI");
          area = PI * radius * radius;
          System.out.println("area is " + area);
          roundArea = Math.round(area);
          System.out.println("Rounded area is " + roundArea);

Change your code to this:
import java.util.*;
public class DebugTwo3
     public static final double PI = 3.14159;
     public static void main(String args[])
          double radius = 2.00;
          double area;
          double roundArea;
          System.out.println("Demonstrating PI");
          area = PI * radius * radius;
          System.out.println("area is " + area);
          roundArea = Math.round(area);
          System.out.println("Rounded area is " + roundArea);
Klint

Similar Messages

  • What's wrong with this simple method

    i'm having compile troubles with this simple method, and i think it's got to be something in my syntax.
    public String setTime()
    String timeString = new String("The time is " + getHours() + ":" + getMinutes() + ":" + getSeconds() + " " + getIsAM());
    return timeString;
    this simple method calls the get methods for hours, minutes, seconds, and isAM. the compiler tells me i need another ) right before getSeconds(), but i don't believe it. i know this is a simple one, but i could use the advice.
    thanks.

    Hi,
    I was able to compile this method , it gave no error

  • Can't gotoAndStop ...what's wrong with this button code?

    Hi,
    I'm totally stumped as to why I can't navigate to another frame.
    I have put 2 days into this simple problem now and I'm ready to give up and go back to AS2.
    Please help!
    I'm using CS4; publish settings AS3, 10.0
    I have a button on frame 2 that should take me to frame 3 when clicked.
    (So far I've tried a hundred different ways but I don't get to frame 3...)
    Different things I tried...
    > Creating the button dynamically from the library...
    > Inserting it statically from the library on frame 2...
    > referencing the mainTimeline through a variable...
    > wrapping the gotoAndStop action in another function...(if placed directly on the timeLine the movie correctly goes straight to frame 3)
    > naming frame 3...
    > using 'nextFrame' instead of 'gotoAndStop'...
    etc..
    In most cases I don't get an error in the output panel and no compiler error either; it just doesn't work!!!
    (Just stays on the same frame after I click the button)
    Here's the code I think should work; but doesn't:
    function moveTo3 (event:MouseEvent):void {
        trace("button_clicked"); // always traces correctly; but movie does not go to frame 3 !!!
        gotoAndStop(3);
    f_btn.addEventListener(MouseEvent.CLICK, moveTo3);
    WHAT AM I MISSING HERE?
    Thanks in advance ...

    Hi Ned,
    I have to run out and don't have the time to deal with it right now but you're RIGHT.
    I do have an 'onEnterFrame' listener on frame 1 !
    It's doing some animation with a symbol and I don't think I removed the listener itself.
    I just set the object to null when it reached [alpha:0].
    THANKS!
    I'll check it out as soon as I can but I really think you got me looking in the right direction now.
    Thanks again,
    Connor
    (I'll post an update when I get back to it)

  • What's wrong with this mini-code? (Trying to draw graphics).

    Could someone please help me fix what's wrong the following test-program?:
    package project;
    import java.awt.Graphics;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class GraphicsTester extends JPanel
        JPanel thePanel = this;
        public void GraphicsTester()
            JFrame frame = new JFrame();
            frame.setSize(600,600);
            frame.add(thePanel);
            frame.setVisible(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            g.drawRect(50, 50, 50, 50);
            System.out.println("Sup fool");
        public static void main(String[] args)
            GraphicsTester gt = new GraphicsTester();
            System.out.println("works2");
    }Any help would be greatly appreciated!
    Thanks in advance!

    Also, all Swing code should be called from the Event Dispatch Thread. It probably isn't hurting much in your case. But, in the body of main, do this (instead of the comment, put what you currently have as the body of main):
    EventQueue.invokeLater(
    new Runnable()
          public void run()
              // Your current body of main.
      });

  • What's wrong with this button code

    Dear All,
    I am trying to set up a button handler for many buttons
    rather just one. The
    intention of this code is to say if I press Load1 to Load40
    that button and
    only that button's alpha should change to 50%. This code
    makes them all 50%
    alpha when the frame loads rather than on the onPress event.
    Can someone please help me out with this one?
    i = 0;
    while (i<40) {
    this["Load"+i].onPress = btnEvaluate(this["Load"+i]);
    ++i;
    function btnEvaluate(target_btn:Button) {
    target_btn._alpha = 50;
    Thanks again.
    Alastair MacFarlane

    kglad,
    Thanks again. What would this group do without your help.
    Alastair
    "kglad" <[email protected]> wrote in message
    news:gh0sq0$cbv$[email protected]..
    > :
    >
    >
    >
    > for (var i = 0;i<40;i++) {
    > this["Load"+i].onPress =function(){
    > this._alpha=50;
    > }
    > }

  • What is wrong with this simple query

    Hi,
    I am writting a simple code just to get the maximum no values from a database table
    The query is
    ResultSet = stm.executeQuery("SELECT MAX(column_name) FROM Database_table ");
    it seems to be a simple one but i am getting the message
    column not found
    Please answer soon

    Well, it depends on how your resultset is retrieving the results. If you retrieve by column name, then that's your problem. You need to do something like this:
    ResultSet = stm.executeQuery("SELECT MAX(column_name) AS myColumnName FROM Database_table ");
    String myResult = ResultSet.getString(myColumnName);Using MAX, COUNT, etc, will return your result with a mangled or no actual column name to retrieve from. Optionally, you can solve your problem by:
    ResultSet.getString(1);Michael Bishop

  • What is wrong with this simple PL/SQL..

    Hello,
    I made a PL/SQL to recreate user (if user exits already, then drop/recreate)
    I run this script and it won't drop the existed user as expected, what is wrong..?
    run like:
    $ sqlplus system/password@dbname @create_user.sql 'A1' --A1 is a user who already existed.
    conn /as sysdba
    SET FEEDBACK OFF SERVEROUTPUT ON VERIFY OFF TERMOUT OFF
    DECLARE
    v_count INTEGER := 0;
    v_statement VARCHAR2 (200);
    BEGIN
    SELECT COUNT (1)
    INTO v_count
    FROM dba_users
    WHERE username = UPPER ('&1');
    IF v_count != 0
    THEN
    EXECUTE IMMEDIATE ('DROP USER &1 CASCADE');
    END IF;
    v_statement :=
    'CREATE USER &1 IDENTIFIED BY &1'
    || ' DEFAULT TABLESPACE USER_DATA'
    || ' TEMPORARY TABLESPACE TEMPORARY_DATA'
    || ' PROFILE DEFAULT ACCOUNT UNLOCK';
    EXECUTE IMMEDIATE (v_statement);
    -- Grant permissions
    EXECUTE IMMEDIATE ('GRANT READ_USER TO &1 WITH ADMIN OPTION');
    EXECUTE IMMEDIATE ('ALTER USER &1 DEFAULT ROLE ALL');
    EXECUTE IMMEDIATE ('GRANT CREATE PUBLIC SYNONYM TO &1');
    EXECUTE IMMEDIATE ('GRANT CREATE DATABASE LINK TO &1');
    EXECUTE IMMEDIATE ('GRANT CREATE SNAPSHOT TO &1');
    EXECUTE IMMEDIATE ('GRANT CREATE TABLE TO &1');
    EXECUTE IMMEDIATE ('GRANT DROP PUBLIC SYNONYM TO &1');
    EXECUTE IMMEDIATE ('GRANT QUERY REWRITE TO &1');
    EXECUTE IMMEDIATE ('GRANT RESTRICTED SESSION TO &1');
    EXECUTE IMMEDIATE ('GRANT SELECT ANY DICTIONARY TO &1');
    EXECUTE IMMEDIATE ('GRANT SELECT ANY TABLE TO &1');
    EXECUTE IMMEDIATE ('GRANT UNLIMITED TABLESPACE TO &1');
    EXECUTE IMMEDIATE ('GRANT SELECT ON SYS.CHANGE_TABLES TO &1');
    EXECUTE IMMEDIATE ('GRANT SELECT ON SYS.DBA_SUBSCRIBED_TABLES TO &1');
    EXECUTE IMMEDIATE ('GRANT SELECT ON SYS.DBA_SUBSCRIPTIONS TO &1');
    EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_CDC_PUBLISH TO &1');
    EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_CDC_SUBSCRIBE TO &1');
    EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_CDC_UTILITY TO &1');
    EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_LOCK TO &1');
    EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_SYSTEM TO &1');
    EXECUTE IMMEDIATE ('GRANT EXECUTE ON SYS.DBMS_UTILITY TO &1');
    EXECUTE IMMEDIATE ('GRANT READ, WRITE ON DIRECTORY SYS.PUBLIC_ACCESS TO &1 WITH GRANT OPTION');
    DBMS_OUTPUT.put_line (' ');
    DBMS_OUTPUT.put_line ('User &1 created successfully');
    DBMS_OUTPUT.put_line (' ');
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line (SQLERRM);
    DBMS_OUTPUT.put_line (' ');
    END;
    Exit;
    EOF
    Thank you
    Jerry

    Hi,
    I try to run this command in a shel scriptl, following this pl/sql excuting is a exp core shcema/imp to this user by using pipe.
    (--this part is working well)
    so I try to debug the pl/sql part first that is why I didn't use & or &&, which need to interactive with computer on scene, but this shell script will run automatically by scheduler.
    this is the whole shell,
    #!/bin/ksh
    INPUT_DATABASE_SCHEMA=$1
    OUTPUT_DATABASE_SCHEMA=$2
    TARGET_DATABASE=$3
    #drop/recreate user $2
    sqlplus system/$3@$3 @create_user.sql '$2' ---this is also the question? how make it as real variable $2, not literal
    #exp
    mknod ./$1_exp p
    gzip < $1_exp > ./$1_exp.dmp.gz &
    exp \
    rows=y \
    userid=system/$3@$3 \
    owner=$1 \
    log=$1_exp.log \
    file=$1_exp \
    direct=y \
    recordlength=65535 \
    statistics=none \
    consistent=y \
    compress=n \
    grep 'ORA-' $1_exp.log
    if [ $? = 0 ]
    then
    mail -s "Problem in regression snapshort export" email < $1_exp.log
    fi
    #imp
    mknod ./$1_exp p
    gunzip < $1_exp.dmp.gz > $1_exp &
    imp \
    userid=system/$3@$3 \
    file=$1_exp \
    log=$2_IMP.log \
    buffer=500000000 \
    ignore=y \
    commit=y \
    fromuser=$1 \
    touser=$2 \
    feedback=100000 \
    GRANTS=n \
    grep 'ORA-' $2_IMP.log
    if [ $? = 0 ]
    then
    mail -s "Erros found in regression snapshort import" email < $2_IMP.log
    else
    mail -s "regression snapshort is done sucessfully" email < $2_IMP.log
    fi
    #recompile invalid
    sqlplus system/$3@$3 << EOF
    conn /as sysdba
    @?/rdbms/admin/utlrp.sql
    Exit;
    EOF
    thank you in advance

  • What's wrong with this widget code?

    Hi everyone,
    (I hope this is a good place to put this) I'm trying to build a widget in Dashcode, and one of the things I want to do is run a system command (specifically "ps -ax"). I enabled command line access in the widget attributes, and I now have:
    var processes = widget.system("/bin/ps -ax", NULL);
    The problem is that "processes" is always undefined. I read on here that there's a bug that if the output is too long, then the variable is undefined. So I tried substituting the command with this:
    var processes = widget.system("/bin/ls ~/", NULL);
    When I run the command in Terminal, the output is minimal:
    Desktop Documents Downloads Library Movies Music Pictures Public Sites
    But when I try to run that in Dashcode, it still returns undefined. Am I missing something obvious here?

    bump I'm still at a standstill with this. Any ideas?
    Thanks!

  • What is wrong with this simple JSP code?

    Whenever I run it on a browser it goes the SQL exception, but when I run it in a Java compiler it works fine.
    Any help very much appreciated
    <head>
    <%@ page
         import = "java.io.*"
         import = "java.lang.*"
         import = "java.sql.*"
    %>
    <title>
    JSP Example 2
    </title>
    </head>
    <body>
    <h1>JSP Example 2</h1>
    <%
    try
    // Load the driver class
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         try
         // Define the data source for the driver
              String sourceURL = "jdbc:odbc:my_library";
         // Create a connection through the DriverManager
              Connection databaseConnection = DriverManager.getConnection(sourceURL,"","");
              out.println("Here");
         Statement statement = databaseConnection.createStatement();
         ResultSet authorNames = statement.executeQuery("Select * from tblAvailable_Items");
         catch (SQLException s)
              out.println("SQL Error<br>");
         catch (ClassNotFoundException err)
              out.println("Class loading error");
    %>
    </body>
    </html>

    Hi...
    I have made some modifications to your code.. Try this. I assume, you would configured the system dsn as my_library, a table name "Table1" with one of the fields name as "name"
    <head>
    <%@ page import = "java.io.*,java.lang.*,java.sql.*" %>
    <title>
    JSP Example 2
    </title>
    </head>
    <body>
    <h1>JSP Example 2</h1>
    <%
    try
    // Load the driver class
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    try
    // Define the data source for the driver
    String sourceURL = "jdbc:odbc:my_library";
    // Create a connection through the DriverManager
    Connection databaseConnection = DriverManager.getConnection(sourceURL,"","");
    out.println("Here");
    Statement statement = databaseConnection.createStatement();
    String sql = "select * from Table1";
    ResultSet authorNames = statement.executeQuery(sql);
    while (authorNames.next()){
                             String Name = authorNames.getString("name");
    out.println(Name);
    catch (SQLException s)
    out.println("SQL Error<br>");
    catch (ClassNotFoundException err)
    out.println("Class loading error");
    %>
    </body>
    </html>
    Regds
    Vasi

  • What is wrong with this idoc code snip?

    Hi all here's the code that's supposed to give me a default value for a metadata in check-in:
    1. <$if dDocAccount like "test*"$>
    2. <$dprDefaultValue="Test"$>
    3. <$elseif userHasRole("TesterA") or userHasRole("TesterB")$>
    4. <$dprDefaultValue="A or B"$>
    5. <$elseif userHasRole("TesterC") or userHasRole("TesterD")$>
    6. <$dprDefaultValue="C or D"$>
    7. <$else$>
    8. <$dprDefaultValue="Not A nor B nor C nor D"$>
    9. <$endif$>
    Now if I leave the code like that only the first 2 lines work meaning that if first condition fails then the whole code stops working even though line 3 is true... is there something wrong in just calling dDocAccount on its own? never seen that happen before.
    If I change that first line for <$if *#active.* dDocAccount like "test*"$> then this first condition won't work but the rest (line 3+) does work!
    please help!!

    Hmmmm,
    If your first two lines work if true then the issue is with the elseif lines right?
    userHasRole("foo") returns true or false. Can you wrap userHasRole("foo") in an "isTrue()" function and test that way?
    What about exploding the OR statement and writing a bunch of elseifs to see if it works that way.
    The other thing you can do is to wrap your OR clause itself in parens
    <$elseif ((userHasRole("foo")) or (userHasRole("bar")))$>
    do stuff
    <$endif$>
    let us know what works for you
    Warmly,
    Billy Cripe
    Fishbowl Solutions

  • What is wrong with this simple CFIF statement?

    Hi, I've included a simple cfif statment to check to see if a
    user is already in the database, for some reaons the <cfelse>
    part of the statement does not work. that is, if the user is there
    it returns the recordcount and ID etc. but if it is a new user (no
    records found) it is just blank (without the nothing doing !!!) any
    ideas?
    Thanks
    Yankee

    Based strictly on the code you have shown, you do not need
    the query="getuser" in your cfoutput tag.
    Also, I would check to see if the value is greater than zero
    rather than equal to one. What if the person has more than one
    record in the database?
    Try this...
    <CFIF getuser.recordcount GT 0>
    #GetUser.RecordCount# Records Found
    <CFELSE>
    Doing Nothing
    </CFIF>

  • What is wrong with this trigger code?

    Hi folks,
    Just wondering whether I might be missing something here about Oracle 9i, that one of you might notice, either from the syntax perspective, or regarding a bug? The code below compiles in the database I have, but the trigger does not fire, and no data is being inserted into the tables. The trigger is owned by sys, and the insert statements are in dynamic sql because I don't want the trigger not to compile if ever the tables are deleted from the b1dev schema.
    Incidentally, this same trigger works well on Oracle 10.2.1.0 and Oracle 11.1.0. Any feedback would be much appreciated.
    CREATE OR REPLACE TRIGGER cc_LogOff_Trig
        BEFORE LogOff ON DATABASE
        DECLARE
           LogOff_sid   PLS_INTEGER;
           LogOff_Time  DATE := SYSDATE;
           Table_1      VARCHAR2(30) := 'CC_SESSION_EVENT_HISTORY';
           Table_2      VARCHAR2(30) := 'CC_SESSTAT_HISTORY';
           Table_Count  NUMBER;
           v_sql1       VARCHAR2(4000);
           v_sql2       VARCHAR2(4000);
        BEGIN
          SELECT sId
          INTO   LogOff_sId
          FROM   sys.v$MysTat
          WHERE  ROWNUM < 2;
          SELECT COUNT(* )
          INTO   Table_Count
          FROM   dba_Objects
          WHERE  Object_Name = Table_1
                 AND Object_Type = 'TABLE';
          IF Table_Count = 1 THEN
            v_sql1 := 'INSERT INTO bdev.cc_session_event_history(sid,   serial#,   username,   osuser,   session_process_addr,   os_client_process_id,   logon_time,   type,   event,    total_waits,   total_timeouts,   time_waited_csecs,  
      average_wait_csecs,   max_wait_csecs,    logoff_timestamp) SELECT se.sid, s.serial#, s.username, s.osuser, s.paddr, s.process, s.logon_time, s.type, se.event, se.total_waits, se.total_timeouts, se.time_waited, se.average_wait,
      se.max_wait, '''
                      ||LogOff_Time
                      ||''' FROM sys.v$session_event se, sys.v$session s WHERE se.sid = s.sid AND s.username = '''
                      ||LogIn_User
                      ||''' AND s.sid = '
                      ||LogOff_sId;
            EXECUTE IMMEDIATE v_sql1;
          END IF;
          SELECT COUNT(* )
          INTO   Table_Count
          FROM   dba_Objects
          WHERE  Object_Name = Table_2
                 AND Object_Type = 'TABLE';
          IF Table_Count = 1 THEN
            v_sql2 := 'INSERT INTO bdev.cc_sesstat_history(username,     osuser,   sid,   serial#,   session_process_addr,   os_client_process_id,   logon_time,   statistic#,   name,   VALUE,   logoff_timestamp)   SELECT s.username,   
      s.osuser,      ss.sid,     s.serial#,     s.paddr,     s.process,     s.logon_time,     ss.statistic#,     sn.name,     ss.VALUE,     '''
                      ||LogOff_Time
                      ||'''   FROM sys.v$sesstat ss,     sys.v$statname sn,     sys.v$session s 
      WHERE ss.statistic# = sn.statistic#    AND ss.sid = s.sid    AND sn.name IN(''CPU used when call started'',   ''CPU used by this session'',   ''recursive cpu usage'',   ''parse time cpu'')   
      AND s.username = '''
                      ||Login_User
                      ||''' AND s.sid = '
                      ||LogOff_sId;
            EXECUTE IMMEDIATE v_sql2;
          END IF;
          COMMIT;
        END;
    desc cc_session_event_history;
    Name                           Null     Type                                                                                                                                                                                         
    SID                                     NUMBER                                                                                                                                                                                       
    SERIAL#                                 NUMBER                                                                                                                                                                                       
    USERNAME                                VARCHAR2(30)                                                                                                                                                                                 
    OSUSER                                  VARCHAR2(30)                                                                                                                                                                                 
    SESSION_PROCESS_ADDR                    RAW(0)                                                                                                                                                                                       
    OS_CLIENT_PROCESS_ID                    VARCHAR2(24)                                                                                                                                                                                 
    LOGON_TIME                              DATE                                                                                                                                                                                         
    TYPE                                    VARCHAR2(10)                                                                                                                                                                                 
    EVENT                                   VARCHAR2(64)                                                                                                                                                                                 
    EVENT#                                  NUMBER                                                                                                                                                                                       
    TOTAL_WAITS                             NUMBER                                                                                                                                                                                       
    TOTAL_TIMEOUTS                          NUMBER                                                                                                                                                                                       
    TIME_WAITED_CSECS                       NUMBER                                                                                                                                                                                       
    AVERAGE_WAIT_CSECS                      NUMBER                                                                                                                                                                                       
    MAX_WAIT_CSECS                          NUMBER                                                                                                                                                                                       
    TIME_WAITED_MICRO                       NUMBER                                                                                                                                                                                       
    LOGOFF_TIMESTAMP                        DATE                                                                                                                                                                                         
    17 rows selected
    desc cc_sesstat_history;
    Name                           Null     Type                                                                                                                                                                                         
    USERNAME                                VARCHAR2(30)                                                                                                                                                                                 
    OSUSER                                  VARCHAR2(30)                                                                                                                                                                                 
    SID                                     NUMBER                                                                                                                                                                                       
    SERIAL#                                 NUMBER                                                                                                                                                                                       
    SESSION_PROCESS_ADDR                    RAW(0)                                                                                                                                                                                       
    OS_CLIENT_PROCESS_ID                    VARCHAR2(24)                                                                                                                                                                                 
    LOGON_TIME                              DATE                                                                                                                                                                                         
    STATISTIC#                              NUMBER                                                                                                                                                                                       
    NAME                                    VARCHAR2(64)                                                                                                                                                                                 
    VALUE                                   NUMBER                                                                                                                                                                                       
    LOGOFF_TIMESTAMP                        DATE                                                                                                                                                                                         
    11 rows selected

    I have taken out the 'commit' and have added the 'when others then null' exception clause, but I would imagine there is a better way to do it than this? I don't want to do an insert into another table either. With Oracle 11g, this gives me the compile time warning....
    CREATE OR REPLACE TRIGGER cc_LogOff_Trig
        BEFORE LogOff ON DATABASE
        DECLARE
           LogOff_sid   PLS_INTEGER;
           LogOff_Time  DATE := SYSDATE;
           Table_1      VARCHAR2(30) := 'CC_SESSION_EVENT_HISTORY';
           Table_2      VARCHAR2(30) := 'CC_SESSTAT_HISTORY';
           Table_Count  NUMBER;
           v_sql1       VARCHAR2(4000);
           v_sql2       VARCHAR2(4000);
        BEGIN
          SELECT sId
          INTO   LogOff_sId
          FROM   sys.v$MysTat
          WHERE  ROWNUM < 2;
          SELECT COUNT(* )
          INTO   Table_Count
          FROM   dba_Objects
          WHERE  Object_Name = Table_1
                 AND Object_Type = 'TABLE';
          IF Table_Count = 1 THEN
            v_sql1 := 'INSERT INTO bdev.cc_session_event_history(sid,   serial#,   username,   osuser,   session_process_addr,   os_client_process_id,   logon_time,   type,   event,    total_waits,   total_timeouts,   time_waited_csecs,  
      average_wait_csecs,   max_wait_csecs,    logoff_timestamp) SELECT se.sid, s.serial#, s.username, s.osuser, s.paddr, s.process, s.logon_time, s.type, se.event, se.total_waits, se.total_timeouts, se.time_waited, se.average_wait,
      se.max_wait, '''
                      ||LogOff_Time
                      ||''' FROM sys.v$session_event se, sys.v$session s WHERE se.sid = s.sid AND s.username = '''
                      ||LogIn_User
                      ||''' AND s.sid = '
                      ||LogOff_sId;
            EXECUTE IMMEDIATE v_sql1;
          END IF;
          SELECT COUNT(* )
          INTO   Table_Count
          FROM   dba_Objects
          WHERE  Object_Name = Table_2
                 AND Object_Type = 'TABLE';
          IF Table_Count = 1 THEN
            v_sql2 := 'INSERT INTO bdev.cc_sesstat_history(username,     osuser,   sid,   serial#,   session_process_addr,   os_client_process_id,   logon_time,   statistic#,   name,   VALUE,   logoff_timestamp)   SELECT s.username,   
      s.osuser,      ss.sid,     s.serial#,     s.paddr,     s.process,     s.logon_time,     ss.statistic#,     sn.name,     ss.VALUE,     '''
                      ||LogOff_Time
                      ||'''   FROM sys.v$sesstat ss,     sys.v$statname sn,     sys.v$session s 
      WHERE ss.statistic# = sn.statistic#    AND ss.sid = s.sid    AND sn.name IN(''CPU used when call started'',   ''CPU used by this session'',   ''recursive cpu usage'',   ''parse time cpu'')   
      AND s.username = '''
                      ||Login_User
                      ||''' AND s.sid = '
                      ||LogOff_sId;
            EXECUTE IMMEDIATE v_sql2;
          END IF;
      EXCEPTION
          WHEN OTHERS THEN
             NULL;
        END;Edited by: efachim on Jan 6, 2009 11:30 AM

  • Does any one know what is wrong with this servlet code

    package com.bt.ros;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    * This class is a servlet that searches for a Finder Aid.
    * @author
    public class FinderAidsSearchS extends HttpServlet {
       * This is the static initializer,
       * executed the first time this class is referred to.
       * It makes sure the JDBC pool driver is loaded.
       * This method examines an HTTP request and searches for the
       * specified Finder Aid record in the database. It then redirects
       * the response to the <tt>Results.jsp</tt> JSP page.
      public void service(HttpServletRequest req, HttpServletResponse res)
           throws IOException
        HttpSession session = req.getSession(true);
    //res.setContentType("text/html");
    //PrintWriter out = res.getWriter( );
    //out.println("<HTML>");
    //out.println("<HEAD>");
    //out.println("<TITLE>");
    //out.println("A Servlet Example");
        String year   = req.getParameter("Year");
        String year_range      = req.getParameter("Year_Range");
        String county          = req.getParameter("County");
        Connection conn = null;
        try {
    //example code from tomcatmanual
    Context initContext = new InitialContext();
    Context envContext  = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/rosDS");
    //Connection
    conn = ds.getConnection();
              Statement stmt = conn.createStatement();
          String select = "select * from abridgment where " +
                          "(a_county = '" + county +
                          "' AND a_year_date = " + year +
    out.println("<DEBUG> <select> the select staement is : " + select);
          stmt.execute(select);
          ResultSet resultSet = stmt.getResultSet();
         Results abridgeresults = new Results();
         abridgeresults.setName("NaeemColl");
         Abridgment varabridgment = null;
          int nRows = 0;
          while(resultSet.next()){
            nRows++;
               varabridgment = new Abridgment();
           varabridgment.seta_county(county);
          varabridgment.seta_year_date(Integer.parseInt(year));
            varabridgment.seta_sub_year_volume(resultSet.getInt("a_sub_year_volume"));
           // out.println("varabridgment - attributes are:");
              //out.println("varabridgment - attributes are:" +varabridgment.geta_sub_year_volume());
              //out.println("varabridgment - attributes are:"+resultSet.getInt("a_sub_year_volume"));
              varabridgment.seta_page_id(resultSet.getString("a_page_id"));
            varabridgment.seta_month_date(resultSet.getInt("a_month_date"));
            varabridgment.seta_day_date(resultSet.getInt("a_day_date"));
            varabridgment.seta_year_sequence(resultSet.getLong("a_year_sequence"));
            varabridgment.seta_day_sequence(resultSet.getLong("a_day_sequence"));
            varabridgment.seta_year_volume(resultSet.getInt("a_year_volume"));
            varabridgment.seta_volume_id(resultSet.getString("a_volume_id"));
            varabridgment.seta_summary(resultSet.getString("a_summary"));
            varabridgment.seta_batch_id(resultSet.getLong("a_batch_id"));
            varabridgment.seta_image_id(resultSet.getLong("a_image_id"));
              abridgeresults.addAbridgment(varabridgment);
              //trying to use vector construct
          req.setAttribute("results",abridgeresults);
          //session.setAttribute("results", abridgeresults);
          stmt.close();
          conn.close();
    //out.println("</BODY>");
    //out.println("</HTML>");
    //      String sURL = res.encodeRedirectURL("/rossearch/results.jsp");
            try{
    //TEMPCOMM        res.sendRedirect(sURL);
    req.getRequestDispatcher("/rossearch/results.jsp").forward(req, res);
    //TEMPCODE
    //out.println("</BODY>");
    //out.println("</HTML>");
          catch(Exception e){
            System.err.println("Exception: FinderAidsSearchS.service: " + e);
        catch (Exception e) {
          System.err.println("Exception: FinderAidsSearchS.service: " + e);
    }i really need some assistance at the following areas of code :
    where the database results are set to attributes of one bean varabridgment (Type Abridgement) - the declaration and use of this bean.
    and where this bean is then added to another bean abridgeresults (Type Results) as a List collection.
    i get a null pointer exception when i try to retrieve the List from abridgeresults object of Type Results Bean.
    i would really appreciate some assistance in this - i really need to go to sleep now - but cant until i solve this issue. - thanks all in advance.

    below is exception outputed to tomcat log file.
    it is thrown at the following line of code in the jsp that tries to get the List object :
    currently jsp code to retrieve List: <% List myAbridgments = (List) request.getAttribute("results");
    for (int i = 0; i < myAbridgments.size(); i++) {
    abridgment = (Abridgment) myAbridgments.get(i);
    %>
    line that gives problem is
    (results_jsp.java:95)
    //myAbridgments - is variable where i store the List object in jsp scriptlet
    for (int i = 0; i < myAbridgments.size(); i++) {
    Also, i dont understand why the servlet keeps on forwarding to the results.jsp when i even comment out the line of code to forward request oobject to results.jsp - i recompile copy it over original and restart tomcat - but still i get the null pointer exception in results_jsp - but i'm no longer forwarding anything to this jsp. --- i want to do some out.printline statemets in servelt to see some of the data from the query - but i cant as it just forwrads the request to results.jsp - how can i output the data to look at debug - i dont have a log4j logger setup and dont have IDE to be able to place break points - so wanted to just output stuff to browser to have a look at what was going on - but can't as just forwards request on ?
    Exception ....
    2005-11-07 02:45:20 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:536)
    ----- Root Cause -----
    java.lang.NullPointerException
         at org.apache.jsp.results_jsp._jspService(results_jsp.java:95)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:536)

  • What is wrong with this simple for loop?

    long number = 12345678;
            for(int i=1;i<=numberOfDigits;i++)
                int i = number/(i);
            System.out.println(i);
            Basically, I want to take to assign int 1 = , int 2 = , int 3 = up until the number of digits.
    I still have to manipulate it, so the code makes no sesne, but how would I do that?
    So, i want to assign ints up until 8 but the manipulation I have also involves i up until the number of digits.
    Yhank you.

    Fredddir_Java wrote:
    I see that, but I just wanted to declare 8 ints (in this example, number of digits is 8) using a for loop, so I wanted to use the loop to assign these values one at a time. You know...but don't declare a variable with the same name as the loop variable. That just won't compile. Use an array as mentioned above.
    How would you do that?If you are trying to find the digit at a certain point in your number, probably the easiest way is to translate the number to a Stirng and use String methods (if allowed) such as charAt(...). If not, then look at the mod operator "%" and at integer division.
    Can anyone provide a basic loop for this task?Best not to ask for a code solution to homework here. We'll tolerate specific questions but not requests for code.

  • What is wrong with this simple getText

    Alright, all im trying to do now is to have the user enter in a c d or f for their seat. If they do and everything else is correct, it should place an X in the array. However, even if i do a c d or f, it still goes to the else clause and never performs the intended if structure. I tried with integers and it worked fine, but our prof
    insists we use letters. Please help
    public void actionPerformed (ActionEvent actionEvent) {
    int RowNumber = 0, Section = 0;
    String Seat = "a"; <------------------------------------------declare seat as a string initiated as "a"
    if (actionEvent.getSource() == btnClear){
    txtSeat.setText("");
    txtSection.setText("");
    txtRow.setText("");
    if (actionEvent.getSource() == btnReserve){
    try{
    Section = Integer.parseInt(txtSection.getText());
    RowNumber = Integer.parseInt(txtRow.getText());
    Seat = (txtSeat.getText());<--------------------------------------get the text from txtSeat and put in Seat
    catch(Exception exception){
    JOptionPane.showMessageDialog(null, " Please enter a valid input in each box.");
    if(Section == 1){
    if(RowNumber >= 1 && RowNumber <= 3){
    if(Seat == "a" || Seat == "c" || Seat == "d" || Seat == "f"){<--------------Skips this even if its acd or f
    if(Business[(RowNumber-1)][0] == '0'){
    Business[(RowNumber-1)][0] = 'X';
    JOptionPane.showMessageDialog(null, "Seat has been Reserved.");
    displayChart();
    else JOptionPane.showMessageDialog(null, "Seat is already Reserved.");
    else
    { JOptionPane.showMessageDialog(null, "Please enter a seat A, C, D, or F" + <---------goes here
    " for Business class.");

    1) When posting code use the [url http://forum.java.sun.com/features.jsp#Formatting]Formatting Tags so the code is readable.
    2) if(Seat == "a" || Seat == "c" || Seat == "d" || Seat == "f")
    You don't use "==" when comparing equality of two Objects you use the equals(...) method.
    if (seat.equals("a") ....
    The "==" operator is only used when comparing primitive data types (int, char, long...)
    3) Variable names should not start with an upper case character. Normally class names would start with an upper case character (look at all the classes in the API).

Maybe you are looking for

  • Batch Procedure Not Working For Image Resizing in Fireworks 8

    Scaling graphics with a batch process. You can alter the height and width of images being exported using the Scale option in the Batch Process dialog box. To set scaling options for batch-processed files: Select Scale from the Batch Options list and

  • Mac pro keeps freezing!

    I was organizing photos and caused the first freeze. Now I have restarted the computer 9 times but as soon as the desktop loads it slows down ad freezes. Other users are fine. I have plenty of memory. I tried to go to disc clean up too. <Edited By Ho

  • N80 warranty

    My N80 has the white screen of death, which i'm sure is down too a faulty ribbon cable. Seen as though I've only had the phone for just over a year I took it too a nokia service centre, who told me it was out of warranty. I'm sure I read some where t

  • "Show if" region

    Hi there, DW 8 My question concerns www.sincro.co.za/templates/index.php I have a part that I have selected and marked as a show region when recordset is empty. This means that it must show the words "Log in" when the session is empty. This I have do

  • Sale Order Header Value not flowing

    user created sales order, in item level price displayed correctly, in hedder level it"s choosing 0   can any one give a solution why hedder level thats choose zero Edited by: Lakshmipathi on Apr 21, 2011 3:21 PM Please use the subject effectively