正在做一个东西,要将文本和图片存储在数据库中,
也要求文本和图片同时存储在数据库中,
就是说一个要求存取的内容是图文并茂的。大家有人做过的给我点JAVA的示例代码让我学习下。

解决方案 »

  1.   

    前段时间做过
    将图片和文本
    放到mysql中去
    记得我是用preparedStatement.setBinaryStream(pra,value)
    这个方法放到数据库中去的
    具体我也忘了.........
      

  2.   

    应该可以用blob类型存储图片,用text类型存文字吧.
      

  3.   

    楼主可以将图片和附件等存储在文件夹中,然后将像编辑网页一样编辑你所要发表的文章,将生成的html代码存入数据库。我以前做过一个新闻发布系统就是采用的这样的方法,效果挺不错的。你可以自己用JS和JSP写一个文本编辑器。
      

  4.   

    这个不难吧,数据库都支持二进制的数据的,至于图文并茂,你写个WORD文档,加上文字和图片,再通过流的形式存入数据库即可
    以SQL2000为例://写入数据库
    ...
    InputStream in;
    int length;
    in = .....;
    .........
    PreparedStatement statement = Connect.prepareStatement("update TABLE set content=?");
    statement.setBinaryStream(1,in,length);
    statement.executeUpdate();
    statement.close();
    .......//从数据库读出来
    Statement state = .......;
    OutputStream out = ........;
    ResultSet Rs = state.executeQuery("select content from TABLE);if( Rs.next() ){
        InputStream inword = Rs.getBinaryStream(1);
         if( inword != null){
                byte[] buf = new byte[2048];
                while( true ){
                    int nread = inword.read( buf );
                    if( nread != -1 )
                         out.write( buf , 0 , nread );
                     else break;
                }
         }
         inword.close();
    }
    out.flush();
    out.close();
    Rs.close();
    state.close();要是不行的话就google下"word存入数据库"
      

  5.   

    lz可以试试7楼说的,我刚做过,这对全文检索也很有好处
    ---------------------------------------------------------
    Quietly through ....
      

  6.   


    FormFile file = (FormFile) imageForm.get("file");
    byte[] data = file.getFileData();
    image.setImage(CommonsFiend.base64CodeByteTo64String(data));
    image.setText((String)imageForm.get("text"));
    imageinfoDao.insertImages(image);//jdbc插入操作我是这样做的.
      

  7.   


    FormFile file = (FormFile) imageForm.get("file");
    byte[] data = file.getFileData();
    image.setImage(CommonsFiend.base64CodeByteTo64String(data));
    image.setText((String)imageForm.get("text"));
    imageinfoDao.insertImages(image);//jdbc插入操作我是这样做的.
      

  8.   


    FormFile file = (FormFile) imageForm.get("file");
    byte[] data = file.getFileData();
    image.setImage(CommonsFiend.base64CodeByteTo64String(data));
    image.setText((String)imageForm.get("text"));
    imageinfoDao.insertImages(image);//jdbc插入操作我是这样做的.
      

  9.   

    你存进去的时候是什么格式,取出来就是什么格式,word就是图文并茂的,不晓得你要存的图文并茂是个什么样子,网页文件吗?