使用Blob类型来获取图像文件吧。

解决方案 »

  1.   

    getDate
    public Date getDate(int columnIndex)
                 throws SQLException
    Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language. Parameters:
    columnIndex - the first column is 1, the second is 2, ... 
    Returns:
    the column value; if the value is SQL NULL, the value returned is null 
    Throws: 
    SQLException - if a database access error occurs
    getDate
    public Date getDate(String columnName,
                        Calendar cal)
                 throws SQLException
    Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language. This method uses the given calendar to construct an appropriate millisecond value for the date if the underlying database does not store timezone information. Parameters:
    columnName - the SQL name of the column from which to retrieve the value
    cal - the java.util.Calendar object to use in constructing the date 
    Returns:
    the column value as a java.sql.Date object; if the value is SQL NULL, the value returned is null in the Java programming language 
    Throws: 
    SQLException - if a database access error occurs
    Since: 
    1.2 
      

  2.   

    能告知具体怎么用BLOB 或流吗?
      

  3.   

    转的:一段图片入库的代码,你看看对你有没有帮助:
    /**
      *从数据库获得BLOB字段句炳
      */
      private OutputStream getOutputStream(Connection cn,long ID) throws Exception{
        PreparedStatement st = null;
        OutputStream out = null;
        ResultSet rest = null;
        try{
          String sql = "select content from imagelib where id="+ID;
          st = cn.prepareStatement(sql);
          rest = st.executeQuery();
          if(rest.next()){
            Blob blob = rest.getBlob(1); //获得 blob 对象句柄
            OutputStream blobOs = ((oracle.sql.BLOB)blob).getBinaryOutputStream();
            return blobOs;
          }
          else return null;
        }catch(Exception e){throw e;}
        finally{
          try{
            if(st!=null){
              st.close();
              st = null;
            }
          }catch(Exception e){e.printStackTrace(System.out);}
        }
      }/**
      *图片内容入库
      */
      private void saveContent(Connection cn,Picture picture) throws Exception{
        try{
          OutputStream blobOs = getOutputStream(cn,picture.ID);
          blobOs.write(picture.content);  //内容写入blob,这里picture.content是一个byte[]
          blobOs.close();
        }catch(Exception e){throw e;}
      }