Java 使用JDBC获取BLOB数据时出错

Java 使用JDBC获取BLOB数据时出错,java,oracle,jdbc,blob,Java,Oracle,Jdbc,Blob,我编写了以下代码:- import java.sql.*; import java.util.Properties; import java.io.*; public class Retrieving_Image { public static void main(String[] args) throws Exception{ Properties p = new Properties(); p.put("user", "system");

我编写了以下代码:-

import java.sql.*;
import java.util.Properties;
import java.io.*;

public class Retrieving_Image {

    public static void main(String[] args) throws Exception{

        Properties p = new Properties();
        p.put("user", "system");
        p.put("password", "password");

        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",p);

        PreparedStatement pstmt = con.prepareStatement("select * from picture",ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);            
        ResultSet rs = pstmt.executeQuery();

        rs.first();//retrieving only picture            
        Blob b = rs.getBlob(1);         
        byte arr[] = new byte[(int)b.length()];         
        arr = b.getBytes(1, (int)b.length());

        FileOutputStream fos = new FileOutputStream("result.jpg");
        fos.write(arr);                     
        fos.close();

    }
}
在上面的代码中,我试图检索位于resultset第一行的第一个索引中的图像,事实上resultset只有一行。但我得到了以下错误:-

Exception in thread "main" java.lang.AbstractMethodError: oracle.jdbc.driver.ScrollableResultSet.getBlob(I)Ljava/sql/Blob;
at jdbc.Retrieving_Image.main(Retrieving_Image.java:24)
错误的说法是:-

Blob b = rs.getBlob(1);
我疯了。 如果有人能解释错误,我们将不胜感激。

您能试试:

((OracleResultSet) rs).getBlob(1);
通过在中选择“星”或“*”


您没有指定列顺序,因此不能保证blob将是
结果集中的第一列。请从select语句中删除星号,然后用逗号分隔的列列表重试。然后,您将确定在指定的索引处选择了正确的数据类型。

请参见此处:要读取blob,只需使用
getBinaryStream()
instead@fiscOracleResultSet无法解析为类型
"select * from picture"