Big data object processing consists of two types of fields, CLOB (character large object) and BLOB (binary large object).
Large character objects such as novels can be stored in CLOB, and binary Big Data objects, films, movies, and music can be stored in blobs.
1. Processing CLOB data
Public classJDBCDemo9 {Private StaticMysqlutil Dbutil =NewMysqlutil (); Private Static intAddemp (EMP EMP)throwsexception{Connection Conn=dbutil.getconnection (); String SQL= "INSERT into EMP2 values (null,?,?,?,?)"; PreparedStatement pstmt=conn.preparestatement (SQL); Pstmt.setstring (1, Emp.getname ()); Pstmt.setdouble (2, Emp.getsalary ()); Pstmt.setint (3, Emp.getage ()); File Context= Emp.getcontext ();//Get FileInputStream InputStream =NewFileInputStream (context); Pstmt.setasciistream (4, Inputstream,context.length ()); intresult =pstmt.executeupdate (); Dbutil.close (PSTMT, conn); returnresult; } Public Static voidGetemp (intIdthrowsexception{Connection Conn=dbutil.getconnection (); String SQL= "SELECT * from EMP2 where id=?"; PreparedStatement pstmt=conn.preparestatement (SQL); Pstmt.setint (1, id); ResultSet RS=Pstmt.executequery (); if(Rs.next ()) {String name= rs.getstring ("name"); DoubleSalary =rs.getdouble ("salary"); intAge = Rs.getint ("Age"); Clob C= Rs.getclob ("Context"); String Context= C.getsubstring (1, (int) c.length ()); System.out.println ("EMP Name:" +name+ ", Salary:" +salary+ ", Age" +age+ ", context" +context); } dbutil.close (PSTMT, conn); } Public Static voidMain (string[] args)throwsexception{/*file context = new file ("D:/helloworld.txt"); EMP emp = new EMP ("HelloWorld", 100,100,context); int result = Addemp (EMP); if (result==1) {System.out.println ("add success"); }else{System.out.println ("Add failed"); }*/Getemp (11); }}
2. Processing Blog Data
JDBC (5)-Working with big data