private OrderVo getCOLB(OrderVo orderVo ,String id) {
/**
* JDBC直连数据库
*/
Connection conn = null;
PreparedStatement stmt = null;
try {
//String url = "jdbc:oracle:thin:@136.24.252.29:9521:test";
//String url = "jdbc:oracle:thin:@106.201.174.220:1521:test";
//String user = "order";
//String pwd = "****";
String url = PropertiesUtil.getPropertiesForUrl("url");
String user = PropertiesUtil.getPropertiesForUrl("user");
String pwd = PropertiesUtil.getPropertiesForUrl("pwd");
CLOB clob = null;
String sql = "SELECT * FROM order.info_order where id= " + id;
DriverManager.registerDriver(new OracleDriver());
conn = DriverManager.getConnection(url, user, pwd);// 得到连接对象
stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
String content = "";
if (rs.next()) {
clob = (oracle.sql.CLOB) rs.getClob("pic_clob1"); // 获得CLOB字段str
content = ClobToString(clob);
orderVo .setPic_x(content);
clob = (oracle.sql.CLOB) rs.getClob("pic_clob2"); // 获得CLOB字段str
content = ClobToString(clob);
orderVo .setPic_y(content);
clob = (oracle.sql.CLOB) rs.getClob("pic_clob3"); // 获得CLOB字段str
content = ClobToString(clob);
orderVo .setPic_z(content);
}
} catch (Exception ex) {
ex.getStackTrace();
} finally {
try {
stmt.close();
conn.close();
} catch (Exception e1) {
e1.getStackTrace();
}
}
return orderVo ;
}
public String ClobToString(CLOB clob) throws SQLException, IOException {
String reString = "";
Reader is = clob.getCharacterStream();// 得到流
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
while (s != null) {// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
sb.append(s);
s = br.readLine();
}
reString = sb.toString();
return reString;
}
/**
* JDBC直连数据库
*/
Connection conn = null;
PreparedStatement stmt = null;
try {
//String url = "jdbc:oracle:thin:@136.24.252.29:9521:test";
//String url = "jdbc:oracle:thin:@106.201.174.220:1521:test";
//String user = "order";
//String pwd = "****";
String url = PropertiesUtil.getPropertiesForUrl("url");
String user = PropertiesUtil.getPropertiesForUrl("user");
String pwd = PropertiesUtil.getPropertiesForUrl("pwd");
CLOB clob = null;
String sql = "SELECT * FROM order.info_order where id= " + id;
DriverManager.registerDriver(new OracleDriver());
conn = DriverManager.getConnection(url, user, pwd);// 得到连接对象
stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
String content = "";
if (rs.next()) {
clob = (oracle.sql.CLOB) rs.getClob("pic_clob1"); // 获得CLOB字段str
content = ClobToString(clob);
orderVo .setPic_x(content);
clob = (oracle.sql.CLOB) rs.getClob("pic_clob2"); // 获得CLOB字段str
content = ClobToString(clob);
orderVo .setPic_y(content);
clob = (oracle.sql.CLOB) rs.getClob("pic_clob3"); // 获得CLOB字段str
content = ClobToString(clob);
orderVo .setPic_z(content);
}
} catch (Exception ex) {
ex.getStackTrace();
} finally {
try {
stmt.close();
conn.close();
} catch (Exception e1) {
e1.getStackTrace();
}
}
return orderVo ;
}
public String ClobToString(CLOB clob) throws SQLException, IOException {
String reString = "";
Reader is = clob.getCharacterStream();// 得到流
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
while (s != null) {// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
sb.append(s);
s = br.readLine();
}
reString = sb.toString();
return reString;
}