java.sql.SQLException: Column Index out of range, 0 < 1

后端 未结 3 1702
无人共我
无人共我 2020-12-11 04:54

I want to display all the images from database. I have written code but that is displaying error java.sql.SQLException: Column Index out of range, 0 < 1. below is the my

相关标签:
3条回答
  • 2020-12-11 05:31

    Column Index should start from 1 and not 0

    http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html#getBlob(int)

    Parameters: columnIndex - the first column is 1, the second is 2, ...

    Should be

    resultSet.getBlob(1) //first column
    
    0 讨论(0)
  • 2020-12-11 05:42

    the statement should be like this

    while (resultSet.next())

    resultSet.getBlob(1);

    col index from 1 to ...

    0 讨论(0)
  • 2020-12-11 05:45
    Blob getBlob(int columnIndex)
                 throws SQLException
    Retrieves the value of the designated column in the current row of this ResultSet object as a Blob object in the Java programming language.
    Parameters:
    columnIndex - the first column is 1, the second is 2, ...
    Returns:
    a Blob object representing the SQL BLOB value in the specified column
    

    You're trying to access column by index 0, while enumeration starts with 1

    0 讨论(0)
提交回复
热议问题