Abdullah047

ReadCLOB

Sep 2nd, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package sqltest;
  7.  
  8. import java.io.File;
  9. import java.io.FileWriter;
  10. import java.io.Reader;
  11. import java.sql.*;
  12.  
  13. /**
  14.  *
  15.  * @author Abdullah
  16.  */
  17. public class ReadCLOB {
  18.     public static void main(String[] args) throws Exception{
  19.         int theChar;
  20.             Reader input;
  21.             String url="jdbc:mysql://localhost:3306/demo?autoReconnect&useSSL=false";
  22.             String user="root";
  23.             String password="abdullah";
  24.             String SQL=
  25.          
  26.                     "SELECT resume FROM employee1 WHERE id=1"
  27.                     ;
  28.              
  29.          
  30.           File file=new File("C://Users//Abdullah//Desktop//RandomText.txt");
  31.           FileWriter FW=new FileWriter(file);
  32.         Connection connect=DriverManager.getConnection(url,user,password);
  33.         Statement NS=connect.createStatement();
  34.         ResultSet result=NS.executeQuery(SQL);
  35.         if(result.next()){
  36.            
  37.   input = result.getCharacterStream("resume");
  38.  
  39.  
  40.       while(   (  theChar=input.read()  ) >0 ){
  41.                 FW.write(  (char) theChar  );
  42.       }
  43.         }
  44.        FW.close();
  45.     }
  46. }
Add Comment
Please, Sign In to add comment