You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/02/22 10:32:14 UTC

[GitHub] guowdxp commented on issue #1910: blob column insert exception: Unknown exception: INSERT INTO column size mismatch value size

guowdxp commented on issue #1910: blob column insert exception: Unknown exception: INSERT INTO column size mismatch value size
URL: https://github.com/apache/incubator-shardingsphere/issues/1910#issuecomment-466351547
 
 
   query blob column no problem。
   
   query java code as follows:
   
       /**
        * blob字段查询测试
        * @param args
        * @throws Exception
        */
       @Test
       public void blobQueryTest() throws Exception {
           Class.forName("com.mysql.jdbc.Driver");
           String sql = "select id,image from images";
           Connection conn = DriverManager.getConnection(url, username, password);
           PreparedStatement ps = conn.prepareStatement(sql);
   
           ResultSet rs = ps.executeQuery(sql);
           if(rs.next()) {
           	Integer id = rs.getInt("id");
           	Blob image = rs.getBlob("image");
           	System.out.println(id);        	
           	InputStream in = image.getBinaryStream();
               OutputStream out = new FileOutputStream("f://3.jpg");
               byte[] buffer = new byte[1024*1024];
               int len = 0;
               int i=0;
               while((len = in.read(buffer)) != -1){
                      out.write(buffer, 0, len);
                      i++;
               }    
               out.close();
               in.close();
           }
           rs.close();
           ps.close();
           conn.close();
       }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services