package test; import com.google.gson.JsonObject; import org.apache.commons.dbcp2.DriverConnectionFactory; import java.io.InputStream; import java.sql.*; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String[] args) throws Exception { Connection connection=getConnection(); ResultSet re = connection.prepareStatement("select * from users ").executeQuery(); // int res = connection.prepareStatement("insert into users values(4,'{\"name\":\"123445\"}')").executeUpdate(); // System.out.println(res+"=================="); List<String> list=new ArrayList<>(); while (re.next()){ InputStream in=re.getBinaryStream("shopInfo"); byte[] bytes=new byte[1024]; StringBuffer stringBuffer=new StringBuffer(); while (in.read(bytes)!=-1){ System.out.println(new String(bytes)); stringBuffer.append(new String(bytes)); } list.add(stringBuffer.toString()); } for (String s :list) { // JSONObject obj= JSON.parseObject(s); // System.out.println(obj.get(“sex”)+”==============_=-“); } re.close(); ResultSet ree = connection.prepareStatement(“select * from users “).executeQuery(); while (ree.next()){ Blob blob =ree.getBlob(“shopInfo”); byte[] bytes=new byte[1024]; InputStream in=blob.getBinaryStream(); while (in.read(bytes)!=-1){ System.out.println(new String(bytes)); } } ree.close(); connection.close(); } public static Connection getConnection()throws Exception{ Class.forName("com.mysql.jdbc.Driver"); Connection connection= DriverManager.getConnection("jdbc:mysql://localhost:xxxx/xxxx?useSSL=false&useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false","root","12ewerwr34"); return connection; }