java - how can I create a long String from a Clob? -
// load database details variables. string url = "jdbc:oracle:thin:@localhost:1521:orcl"; string user = "scott"; string password = "tiger"; // create properties object holds database details properties props = new properties(); props.put("user", user ); props.put("password", password); props.put("setbigstringtryclob", "true"); try { drivermanager.registerdriver(new oracledriver()); connection conn = drivermanager.getconnection( url , props ); // create preparedstatement object preparedstatement pstmt = null; // create resultset hold records retrieved. resultset rset = null; // create sql query statement retrieve records having clob data // database. string sqlcall = query; pstmt= conn.preparestatement(sqlcall); // execute preparestatement rset = pstmt.executequery(); //string clobval = null; // clob value larger 32765 bytes resultset while (rset.next()) { string clobval = rset.getstring(1); system.out.println(clobval); } } catch (sqlexception e) { // todo auto-generated catch block e.printstacktrace(); }
i'm trying convert clob data string using jdbc. have above code returns null database , don't understand why. have made 1 function in oracle converts it's slow in processing.
how can create long string clob using jdbc? i'm using oracle10g
take @ https://docs.oracle.com/javase/tutorial/jdbc/basics/blob.html#retrieve_clob
you should use method getclob(int pos) resultset object . clob object can reader or string getcharacterstream() or getsubstring() methods.
Comments
Post a Comment