Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sqltest;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.Reader;
- import java.sql.*;
- /**
- *
- * @author Abdullah
- */
- public class ReadCLOB {
- public static void main(String[] args) throws Exception{
- int theChar;
- Reader input;
- String url="jdbc:mysql://localhost:3306/demo?autoReconnect&useSSL=false";
- String user="root";
- String password="abdullah";
- String SQL=
- "SELECT resume FROM employee1 WHERE id=1"
- ;
- File file=new File("C://Users//Abdullah//Desktop//RandomText.txt");
- FileWriter FW=new FileWriter(file);
- Connection connect=DriverManager.getConnection(url,user,password);
- Statement NS=connect.createStatement();
- ResultSet result=NS.executeQuery(SQL);
- if(result.next()){
- input = result.getCharacterStream("resume");
- while( ( theChar=input.read() ) >0 ){
- FW.write( (char) theChar );
- }
- }
- FW.close();
- }
- }
Add Comment
Please, Sign In to add comment