JDBC (5)-Working with big data

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.