向oracle数据库中插入xml数据
//插入图层元数据
public static boolean insertLayerMetadata(DataSource ds,String xml,String id)throws SQLException,ClassNotFoundException{
boolean flag=false;
String metadataTableName=DBUtil.getLayerMetadataTableName(ds);
StringBuffer sql = new StringBuffer("INSERT INTO ");
sql.append(metadataTableName).append("(RECORDID, DATACOL) values(?, ?)");
try{
Connection con=DBUtil.getConnection(ds);
logger.info("excute sql:"+sql.toString());
PreparedStatement prest = con.prepareStatement(sql.toString());
XMLType poXML = XMLType.createXML(con, xml);
prest.setString(1, id);
prest.setObject(2, poXML);
prest.execute();
flag=true;
}
catch(SQLException e){
flag=false;
logger.info(e);
throw new SQLException(e);
}catch(ClassNotFoundException e){
flag=false;
logger.info(e);
throw new ClassNotFoundException(e.getMessage());
}
return flag;
};
转载请注明出处,欢迎交流!http://www.cnblogs.com/likehua