Results 1 to 8 of 8
  1. #1
    agangaia is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default java.sql.SQLException: Invalid column name

    I have checked the same below mentioned query in oracle sql developer, it is fetching the output correctly but when i tried to run the query through java. it is giving me java.sql.SQLException: Invalid column name
    ..
    please help me

    Query:
    select collection from delete_queue where QUEUE_STATUS_ID='1' group by collection

    programmatically running the query:

    String selectString="select collection from delete_queue where queue_status_id='1' group by collection ";

    Statement selectStatement = this.conn.createStatement();

    //Execute query and handle ResultSet
    ResultSet results = selectStatement.executeQuery(selectString);

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default

    What driver are you using?
    Is that the full exception?
    Are you sure you're looking at the same db?

  3. #3
    agangaia is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default java.sql.SQLException: Invalid column name

    driver name : oracle.jdbc.driver.OracleDriver

    here is the full exception



    at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:125)
    at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:162)
    at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:227)
    at oracle.jdbc.driver.OracleStatement.get_column_inde x(OracleStatement.java:3086)
    at oracle.jdbc.driver.OracleResultSetImpl.findColumn( OracleResultSetImpl.java:1854)
    at oracle.jdbc.driver.OracleResultSet.getInt(OracleRe sultSet.java:1605)

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default

    That's not the full error.
    Anyway:
    at oracle.jdbc.driver.OracleResultSet.getInt(OracleRe sultSet.java:1605)

    It's being thrown when calling getInt() on the result set. You haven't given us that code.

  5. #5
    agangaia is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default

    List<DeleteQueue> deleteQueue= new Vector<DeleteQueue>();


    String selectString="select collection from delete_queue where queue_status_id='1' group by collection ";

    Statement selectStatement = this.conn.createStatement();

    //Execute query and handle ResultSet
    ResultSet results = selectStatement.executeQuery(selectString);


    deleteQueue = handleResultSetMultiple(results);


    /*--handleresultsetMultiple method----*/
    private List<DeleteQueue> handleResultSetMultiple( ResultSet rs )
    throws SQLException {
    List<DeleteQueue> deleteQueueList = new Vector<DeleteQueue>();

    DeleteQueue deleteQueue = handleResultSetSingle( rs );
    while( deleteQueue != null ) {
    deleteQueueList.add( deleteQueue );
    deleteQueue = handleResultSetSingle( rs );
    }

    return( deleteQueueList );
    }

    private DeleteQueue handleResultSetSingle( ResultSet rs )
    throws SQLException {
    if( ! rs.next() )
    return( null );

    DeleteQueue deleteQueue = new DeleteQueue();

    deleteQueue.setProfileId( rs.getInt( PROFILE_ID_COL ) );
    deleteQueue.setProductName( rs.getString( PRODUCT_NAME_COL ) );//product_name
    deleteQueue.setCollection( rs.getString( COLLECTION_COL ) );//whereCOLLECTION_COL variable whose value is collection
    deleteQueue.setDirection( ( rs.getShort( DIRECTION_COL ) == 0 ) ? DeleteQueue.OPTOUT : DeleteQueue.OPTIN );
    deleteQueue.setGuid( rs.getString( GUID_COL ) );
    deleteQueue.setDeleteId( rs.getInt( DELETE_ID_COL ) );
    deleteQueue.setQueueStatus( QueueStatusDAO.getQueueStatusString( rs.getInt( QUEUE_STATUS_ID_COL ) ) );
    deleteQueue.setStatusDate( rs.getTimestamp( STATUS_DATE_COL ) );
    deleteQueue.setLoadStage( rs.getInt( LOAD_STAGE_COL ) );
    deleteQueue.setErrorMessage( rs.getString( ERROR_MESSAGE_COL ) );
    deleteQueue.setModifiedBy( rs.getString( MODIFIED_BY_COL ) );
    deleteQueue.setModifiedDate( rs.getTimestamp( MODIFIED_DATE_COL ) );

    return( deleteQueue );
    }

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default

    And?
    Which line is throwing that SQLException?

    You have to give us the information, not expect us to guess.
    Also, you should use code tags when posting code, otherwise it's a pain to follow.

  7. #7
    agangaia is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default

    yep I will follow. I am sorry abt that.
    here this line throws exception
    deleteQueue.setProfileId( rs.getInt( PROFILE_ID_COL ) );

  8. #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    you say you are running the query
    Java Code:
    select collection from delete_queue where QUEUE_STATUS_ID='1' group by collection
    and then you get an invalid_column_name error doing
    Java Code:
    deleteQueue.setProfileId( rs.getInt( PROFILE_ID_COL ) );
    Well. What is PROFILE_ID_COL? I assume a String, considering the error. And hopefully that string is "collection" (but seemingly it is not) as that is the only column returned and attempting to "get" any other column will throw the error you're getting.

Similar Threads

  1. Replies: 3
    Last Post: 01-31-2011, 10:46 AM
  2. Replies: 2
    Last Post: 01-07-2011, 12:50 PM
  3. Replies: 1
    Last Post: 04-05-2010, 02:32 AM
  4. java.sql.SQLException: ORA-01722: invalid number
    By balushanmukha in forum JDBC
    Replies: 0
    Last Post: 08-27-2008, 07:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •