不一致的数据类型:预期NUMBER得到了BLOB

时间:2014-04-19 06:58:14

标签: java sql eclipse oracle

我使用Java完成了一个程序,它将一个名称字段和一个图像存储到oracle数据库中。

我正在使用Eclipse Kepler IDE。

如果我正在运行应用程序输出即将发生1条记录受影响。

然后尝试使用

在oracle数据库中查看结果

从imagetable1中选择*

我收到错误

不一致的数据类型:预期NUMBER得到了BLOB

我确信我在代码中没有做错任何事。

所以任何人都可以告诉我这是什么解决方案,这意味着我将如何在oracle数据库中看到结果。

我编写的代码:

public class InsertImage 
{
    public static void main(String args[]) throws SQLException, IOException
    {
          try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con=DriverManager.getConnection(
                       "jdbc:oracle:thin:@localhost:1521:xe","system","askme@123");
              PreparedStatement ps=con.prepareStatement("insert into imagetable1 
                                  values(?,?)");

              ps.setString(1,"Binay");
              FileInputStream fin=new FileInputStream("D:\\Binay\\1355.jpg");
              ps.setBinaryStream(2, fin,fin.available());
              int i=ps.executeUpdate();

              System.out.print(i+"records affeced");
              con.close();
          } 
          catch (ClassNotFoundException e) {
             e.printStackTrace();
         }
    }

0 个答案:

没有答案
相关问题