Processing clob Big Data Objects
Import Java. SQL. sqlexception; import Java. SQL. drivermanager; import Java. SQL. resultset; import Java. SQL. connection; import Java. SQL. preparedstatement; import Java. io. file; import Java. io. fileinputstream; import Java. io. inputstream; Class tester {public static final string dburl = "JDBC: mysql: // localhost: 3306/student"; public static final string dbuser = "root "; public static final string dbpass = "I Nclude "; public static final string dbdriver =" org. gjt. mm. mySQL. driver "; public static void main (string ARGs []) throws exception {connection con = NULL; preparedstatement PS = NULL; string name =" Wang dameng "; string SQL = "insert into text (name, note) values (?,?) "; Class. forname (dbdriver); con = drivermanager. getconnection (dburl, dbuser, dbpass); // this sentence will be left blank every time PS = con. preparestatement (SQL); file F = new file ("D:" + file. separator + "in.txt"); inputstream in = new fileinputstream (f); PS. setstring (1, name); PS. setasciistream (2, In, (INT) F. length (); ps.exe cuteupdate (); In. close (); PS. close (); con. close (); system. out. println ("operation successful! ");}}
Read clob Big Data Objects
Import Java. SQL. connection; import Java. SQL. sqlexception; import Java. SQL. drivermanager; import Java. SQL. preparedstatement; import Java. SQL. resultset; import Java. io. inputstream; import Java. io. file; import Java. io. fileinputstream; import Java. util. extends; Class tester {public static final string dburl = "JDBC: mysql: // localhost: 3306/student"; public static final string dbdriver = "org. gjt. mm. mySQL. Driver "; public static final string dbuser =" root "; public static final string dbpass =" include "; public static void main (string ARGs []) throws exception {connection con = NULL; preparedstatement PS = NULL; resultset rs = NULL; int id = 1; string SQL = "Select name, note from text where id =? "; Con = drivermanager. getconnection (dburl, dbuser, dbpass); PS = con. preparestatement (SQL) paips.setint(1. id1_rs1_ps.exe cutequery (); If (RS. next () {string name = Rs. getstring (1); stringbuffer sb = new stringbuffer (); system. out. println ("name:" + name); inputstream in = Rs. getasciistream (2); scanning scan = new scanning (in); // scan the eye. usedelimiter ("\ r \ n"); While (scan. hasnext () {sb. append (scan. next ()). append ("\ n");} system. out. println (SB); In. close ();} Rs. close (); PS. close (); con. close ();}}
Clob Big Data Object