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

Similar Messages

  • 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

  • Can someone tell me what's wrong with this LOV query please?

    This query works fine..
    select FILTER_NAME display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = 'ADAM'
    But this one..
    select FILTER_NAME display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = apex_application.g_user
    Gives the following error.
    1 error has occurred
    * LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Thanks very much,
    -Adam vonNieda

    Ya know, I still don't know what's wrong with this.
    declare
    l_val varchar2(100) := nvl(apex_application.g_user,'ADAM');
    begin
    return 'select filter_name display_value, filter_id return_value
    from otmgui_filter where username = '''|| l_val || '''';
    end;
    Gets the same error as above. All I'm trying to do is create a dropdown LOV which selects based on the apex_application.g_user.
    What am I missing here?
    Thanks,
    -Adam

  • What's wrong with this ejb-query?

    Hi people,
    may be i worked too much, may be i've just missed something, but guys, can enyone tell me what the hell is wrong with this GOD DAMNED query?
    <ejb-ql>Select Object(adt) From AddrDataTable AS adt, IN (adt.addresseeQualities) AS aq WHERE adt.season.id = ?1 And aq.aQTemplate.id=?2</ejb-ql>
    That JBoss throws following exception:
    org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'Select Object(adt) From AddrDataTable AS adt, IN (adt.addresseeQualities) AS aq WHERE adt.season.id = ?1 And aq.aQTemplate.id=?2'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "1" at line 1, column 103.
    Was expecting one of:
    "ABS" ...
    "LENGTH" ...
    "LOCATE" ...
    "SQRT" ...
    "+" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <NUMERIC_VALUED_PARAMETER> ...
    <NUMERIC_VALUED_PATH> ...
    at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.<init>(JDBCEJBQLQuery.java:50)
    The worst thing is that when i remove WHERE clause JBoss keeps silence like a fish - it works fine!
    So, any ideas about this?
    Thank you

    Are you sure the ?1 and ?2 parameters exist in the method for which the query is addressed.
    In the statement adt.season.id I guess season is a CMR field and then season has a CMP field called id
    and the same for aq.aQTemplate.id, aQTemplate being the CMR field and the is being a CMP field in the CMR.
    and in adt.addresseeQualities is a CMR field?
    Looks like a complex query
    SELECT OBJECT(adt) from BEAN AS adt,
    IN(adt.CMR_FIELD) AS aq
    WHERE
    adt.ANOTHER_CMR.ANOTHER_AMR_CMP_FIELD=?1
    AND
    aq.2_CMR_FIELD.2_CMP_FIELD =?2

  • 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

  • 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 sql query?  Help

    hi
    i am having difficulty executing this query
    ResultSet s=st.executeQuery("select * from employee where iden = ?"+id);
    here in my program st is statement obg
    iden is attribute name in table
    id i am getting at run time from user
    please help...it says wrong number of parameters
    thank you

    That's correct, get rid of the Question mark. Questions marks are used in PreparedStatements, but they are also used in pattern matching. I am assuming the iden is the table identity. Therefore, I am assuming it is numeric. If so, you can't use the question mark because pattern matching is only done with strings. If you are treating your statement as a PreparedStatement, then you have done it wrong. (See the API) Here is a code snippet from the API:PreparedStatement pstmt =     
       con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?");
    pstmt.setBigDecimal(1, 153833.00)
    pstmt.setInt(2, 110592)It seems you are using a Statement object, so, you need to get rid of that question mark.
    tajenkins

  • 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's wrong with this simple java file

    I am learning java input methods. When I tried to compile the below simple java file, there were two errors.
    import java.io.*;
    public class MainClass {
       public static void main(String[] args)  {
        Console console = System.console();
        String user = console.readLine("user: ");
        System.out.println(user);
    }The compiler errors:
    h:\java\MainClass.java:5: cannot resolve symbol
    symbol : class Console
    location: class MainClass
    Console console = System.console();
    ^
    h:\java\MainClass.java:5: cannot resolve symbol
    symbol : method console ()
    location: class java.lang.System
    Console console = System.console();
    ^
    2 errors
    Could anyone take a look and shed some lights on this?

    I have changed to "import java.io.Console;" but this below errors:
    h:\java\MainClass.java:1: cannot resolve symbol
    symbol : class Console
    location: package io
    import java.io.Console;
    ^
    h:\java\MainClass.java:5: cannot resolve symbol
    symbol : class Console
    location: class MainClass
    Console console = System.console();
    ^
    h:\java\MainClass.java:5: cannot resolve symbol
    symbol : method console ()
    location: class java.lang.System
    Console console = System.console();
    ^
    3 errors
    -----------

  • Wat is wrong with this simple query ???

    I am using 10gxe.
    Below is the query which is not working
    Whenever i am executing it a pop up windows is coming up
    and asking me to enter bind variables ..wat shall i do ???
    Here is a prntscrn of the issue .
    http://potupaul.webs.com/at.html
    VARIABLE g_message VARCHAR2(30)
    BEGIN
    :g_message := 'My PL/SQL Block Works';
    END;
    PRINT g_message
    Edited by: user4501184 on May 18, 2010 12:42 AM

    sqlplus "system/sm@test"
    SQL*Plus: Release 10.2.0.2.0 - Production on Tue May 18 12:45:05 2010
    Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> VARIABLE g_message VARCHAR2(30)
    SQL> BEGIN
    2 :g_message := 'My PL/SQL Block Works';
    3 END;
    4 /
    PL/SQL procedure successfully completed.
    SQL> PRINT g_message;
    G_MESSAGE
    My PL/SQL Block Works
    SQL>

  • 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 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).

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • What's wrong with this SQL?

    what's wrong with this SQL?
    Posted: Jan 16, 2007 9:35 AM Reply
    Hi, everyone:
    when I insert into table, i use the fellowing SQL:
    INSERT INTO xhealthcall_script_data
    (XHC_CALL_ENDED, XHC_SWITCH_PORT, XHC_SCRIPT_ID, XHC_FAX_SPECIFIED)
    VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N'
    FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION
    SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
    I always got an error like;
    VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT,
    ERROR at line 3:
    ORA-00936: missing expression
    but I can't find anything wrong, who can tell me why?
    thank you so much in advance
    mpowel01
    Posts: 1,516
    Registered: 12/7/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:38 AM in response to: jerrygreat Reply
    For starters, an insert select does not have a values clause.
    HTH -- Mark D Powell --
    PP
    Posts: 41
    From: q
    Registered: 8/10/06
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:48 AM in response to: mpowel01 Reply
    Even I see "missing VALUES" as the only error
    Eric H
    Posts: 2,822
    Registered: 10/15/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:54 AM in response to: jerrygreat Reply
    ...and why are you doing a UNION on the exact same two queries?
    (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:55 AM in response to: mpowel01 Reply
    Hi,
    thank you for your answer, but the problem is, if I deleted "values" as you pointed out, and then execute it again, I got error like "ERROR at line 3:
    ORA-03113: end-of-file on communication channel", and I was then disconnected with server, I have to relogin SQLplus, and do everything from beganing.
    so what 's wrong caused disconnection, I can't find any triggers related. it is so wired?
    I wonder if anyone can help me about this.
    thank you very much
    jerry
    yingkuan
    Posts: 1,801
    From: San Jose, CA
    Registered: 10/8/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:59 AM in response to: jerrygreat Reply
    Dup Post
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:00 AM in response to: Eric H Reply
    Hi,
    acturlly what I do is debugging a previous developer's scipt for data loading, this script was called by Cron work, but it never can be successfully executed.
    I think he use union for eliminating duplications of rows, I just guess.
    thank you
    jerry
    mpowel01
    Posts: 1,516
    Registered: 12/7/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:03 AM in response to: yingkuan Reply
    Scratch the VALUES keyword then make sure that the select list matches the column list in number and type.
    1 insert into marktest
    2 (fld1, fld2, fld3, fld4, fld5)
    3* select * from marktest
    UT1 > /
    16 rows created.
    HTH -- Mark D Powell --
    Jagan
    Posts: 41
    From: Hyderabad
    Registered: 7/21/06
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:07 AM in response to: jerrygreat Reply
    try this - just paste the code and give me the error- i mean past the entire error as it is if error occurs
    INSERT INTO xhealthcall_script_data
    (xhc_call_ended, xhc_switch_port, xhc_script_id,
    xhc_fax_specified)
    SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
    hh_switchport, hh_script, 'N'
    FROM tmp_healthhit_load
    WHERE hh_script != 'BROCHURE'
    UNION
    SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
    hh_switchport, hh_script, 'N'
    FROM tmp_healthhit_load
    WHERE hh_script != 'BROCHURE';
    Regards
    Jagan
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 11:31 AM in response to: Jagan Reply
    Hi, Jagan:
    thank you very much for your answer.
    but when I execute it, I still can get error like:
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    so wired, do you have any ideas?
    thank you very much

    And this one,
    Aother question about SQL?
    I thought I already told him to deal with
    ORA-03113: end-of-file on communication channel
    problem first.
    There's nothing wrong (syntax wise) with the query. (of course when no "value" in the insert)

Maybe you are looking for

  • Settings can no longer be searched after KB2919355

    I installed this big milestone update KB2919355 about an hour ago.  I heard so many good words about it and I was eager to get it. I have noticed that searching settings no longer works.  It was working before the update.  I installed the update alon

  • Thinest Protection Case For My Blackberry Curve 8900

    Hi, I'm after some kind of protection that I can put on my blackberry. I want to add the least bulk as possible onto my phone. Can anyone advise me on what I could buy for this? I would like something that will stay on my phone and not any kind of po

  • Need the Logic for this Prg issue Pls

    Hi Friends, i have an urgent requirement.. i am develop the report that is : Based on Selction Critirea kunnr(knvv-kunnr) i want Delete the          Internet mail (SMTP) address FROM ADR6-MTP_ADDR AND Teletex number FROM ADR4-TTX_NUMBER.. USING TABLE

  • Cascading detetion problem

    sir i facing problem only in delete case i have master detail form i set cascade relation when i delete button code is go_block('chartofacc');      delete_record; commit_form;      when press exit button system ask me do you want to save change i pre

  • How do i delete music videos of my i phone 4

    how do i delete music videos of my  i phone 4