cymlancy
来源:互联网 发布:vsftpd 指定端口 编辑:程序博客网 时间:2024/06/06 02:53
DB文件:
package org.travel.www73hi.feed;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DB {
public Connection getConnection() throws SQLException{
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.0.0:orcl","用户名","密码");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
}
//全量文件
package org.travel.www73hi.feed2;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
public class FullIndex {
//服务器
protected void run() {
String sql = "select id from t_circuitry where name like '品质游%【旅游担保】'";
String path = File.separator+"travel_platform"+File.separator;
//取得数据库连接
DB db = new DB();
Connection conn = null;
try {
conn = db.getConnection();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ResultSet rs = null;
PreparedStatement ps = null;
try {
//获取数据
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
Document document = DocumentHelper.createDocument();
document.setXMLEncoding("UTF-8");
Element rootElement = document.addElement("root");
Element versionElement = rootElement.addElement("version");
versionElement.setText("1.0");
Element modifiedElement = rootElement.addElement("modified");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
// cal.add(Calendar.MINUTE, 30);
modifiedElement.setText(df.format(cal.getTime()));
Element seller_idElement = rootElement.addElement("seller_id");
seller_idElement.setText("公司名称");
Element cat_url_idElement = rootElement.addElement("cat_url");
//cat_url_idElement.setText(path+"xml/SellerCats.xml");//linux系统
cat_url_idElement.setText("http://域名/xml/SellerCats.xml");
Element dirElement = rootElement.addElement("dir");
//dirElement.setText(path+"xml/item/");//linux系统
dirElement.setText("http://域名/xml/item/");
Element item_idsElement = rootElement.addElement("item_ids");
while(null!=rs&&rs.next()){
Element outer_idElement = item_idsElement.addElement("outer_id");
outer_idElement.addAttribute("action", "upload");
outer_idElement.setText(rs.getString(1));
}
try {
//生成文件
//XMLWriter output = new XMLWriter(new FileOutputStream(new File(path+"xml/FullIndex.xml")),format);
XMLWriter output = new XMLWriter(new FileOutputStream(new File("C:/Program Files/apache-tomcat-6.0.32/webapps/travel_platform/xml/FullIndex.xml")),format);
output.write(document);
output.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (ps != null) {
ps.close();
ps = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] argv) throws SQLException{
FullIndex dom4j=new FullIndex();
dom4j.run();
System.out.println("************finish*************");
}
}
//增量文件
package org.travel.www73hi.feed2;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimerTask;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
public class Increate {
public void run() {
String sql = " select id ,status from t_circuitry where name like '品质游%【旅游担保】'";
String path = File.separator+"travel_platform"+File.separator;
//取得数据库连接
DB db = new DB();
Connection conn = null;
try {
conn = db.getConnection();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ResultSet rs = null;
PreparedStatement ps = null;
try {
//获取数据
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
Document document = DocumentHelper.createDocument();
document.setXMLEncoding("UTF-8");
Element rootElement = document.addElement("root");
Element versionElement = rootElement.addElement("version");
versionElement.setText("1.0");
Element modifiedElement = rootElement.addElement("modified");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, 30);
modifiedElement.setText(df.format(cal.getTime()));
Element seller_idElement = rootElement.addElement("seller_id");
seller_idElement.setText("公司名称");
Element cat_url_idElement = rootElement.addElement("cat_url");
//cat_url_idElement.setText(path+"xml/SellerCats.xml");//linux系统
cat_url_idElement.setText("http://域名/xml/SellerCats.xml");
Element dirElement = rootElement.addElement("dir");
//dirElement.setText(path+"xml/item/");//linux系统
dirElement.setText("http://域名/xml/item/");
Element item_idsElement = rootElement.addElement("item_ids");
while(null!=rs&&rs.next()){
Element outer_idElement =item_idsElement.addElement("outer_id");
String status = rs.getString(2);
System.out.println(status);
String poid = rs.getString(1);
if(null!=status&&!("NORMAL".equals(status))){
outer_idElement.addAttribute("action", "delete");
outer_idElement.setText(poid);
}
if(null!=status&&"NORMAL".equals(status)){
outer_idElement.addAttribute("action", "upload");
outer_idElement.setText(poid);
}
}
try {
//生成文件
//XMLWriter output = new XMLWriter(new FileOutputStream(new File(path+"xml/IncrementIndex.xml")),format);
XMLWriter output = new XMLWriter(new FileOutputStream(new File("C:/Program Files/apache-tomcat-6.0.32/webapps/travel_platform/xml/IncrementIndex.xml")),format);
output.write(document);
output.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (ps != null) {
ps.close();
ps = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] argv) throws SQLException{
Increate dom4j=new Increate();
dom4j.run();
System.out.println("************finish*************");
}
}
//item文件
package org.travel.www73hi.feed2;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
public class Items {
public void generateDocument() throws SQLException {
String sql = "select * from t_circuitry where name like '品质游%【旅游担保】'";
String path = File.separator + "travel_platform" + File.separator;
// 获取数据库连接
DB db = new DB();
Connection conn = db.getConnection();
ResultSet rs = null;
ResultSet rs1 = null;
ResultSet rs2 = null;
PreparedStatement ps = null;
try {
// DirectoryOpr.delFolder("C:/Program Files/Tomcat5.5/webapps/web/xml/item");
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
int i = 1;
while (rs.next()) {
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
Document document = DocumentHelper.createDocument();
document.setXMLEncoding("UTF-8");
Element itemElement = document.addElement("item");
Element seller_idElement = itemElement.addElement("seller_id");
seller_idElement.setText("公司名称");
Element outer_idElement = itemElement.addElement("outer_id");
outer_idElement.setText(rs.getString("id") == null ? "" : rs
.getString("id"));
Element titleElement = itemElement.addElement("title");
titleElement.setText(rs.getString("name") == null ? "" : rs
.getString("name"));
Element typeElement = itemElement.addElement("available");
typeElement.setText("10");
Element priceElement = itemElement.addElement("price");
String hq = "select a.outprice,b.gooutteamdate, b.circuitryid from t_quoteprice a,t_plan b,t_circuitry c where a.planid=b.id and a.seq=1 and b.circuitryid='"+rs.getString("id")+"' and to_char(b.gooutteamdate,'yyyy-mm-dd') > =to_char(sysdate,'yyyy-mm-dd') and rownum =1";
ps = conn.prepareStatement(hq);
rs2 = ps.executeQuery();
while (rs2.next()) {
String priceParam = String.valueOf(rs2
.getString("outprice"));
System.out.println(priceParam);
System.out.println(rs.getString("id"));
if(priceParam.indexOf(".")<0){
priceParam = priceParam +".00"; }
priceElement.setText(priceParam);
}
// System.out.println("=================>"+priceParam);
sql = " select * from t_attachment where relationid='"
+ rs.getString("id") + "' and type='LITTLEPIC'";
i++;
// 取得数据
ps = conn.prepareStatement(sql);
rs1 = ps.executeQuery();
Element imageElement = itemElement.addElement("image");
imageElement
.setText("http://域名/picture/circuitryPictrue/JSZX1003112001042/1.jpg");
while (rs1.next()) {
imageElement.setText("http://www.axtrip.com"
+ rs1.getString("filepath"));
}
// http://域名/picture/circuitryPictrue/JSZX1003112001042/1.jpg
Element scidsElement = itemElement.addElement("scids");
scidsElement.setText(i + "");
Element post_feeElement = itemElement.addElement("post_fee");
post_feeElement.setText("1.00");
Element hrefElement = itemElement.addElement("href");
hrefElement
.setText("http://域名/www73hiWeb.go?method=viewCircuitry&circuitryId="
+ rs.getString("id"));
try {
// 循环生成文件
XMLWriter output = new XMLWriter(new FileOutputStream(
new File(
"C:/Program Files/apache-tomcat-6.0.32/webapps/travel_platform/xml/item/"
+ rs.getString("id") + ".xml")),
format);
/* XMLWriter output = new XMLWriter(new FileOutputStream(
new File(path+"xml/item/" + rs.getString("id")+ ".xml")),
format);*/
output.write(document);
output.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
System.out.println("一淘Items的任务调度!!!");
try {
if (rs2 != null) {
rs2.close();
rs2 = null;
}
if (rs1 != null) {
rs1.close();
rs1 = null;
}
if (rs != null) {
rs.close();
rs = null;
}
if (ps != null) {
ps.close();
ps = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] argv) throws SQLException {
Items dom4j = new Items();
dom4j.generateDocument();
System.out.println("************finish*************");
}
}
//sellerCate文件
package org.travel.www73hi.feed2;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
public class XmlSellerCats {
protected void executeInternal() {
String sql = " select * from t_circuitry where name like '品质游%【旅游担保】'";
String path = File.separator+"travel_platform"+File.separator;
//取得数据库连接
DB db = new DB();
Connection conn = null;
try {
conn = db.getConnection();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ResultSet rs = null;
PreparedStatement ps = null;
try {
//获取数据
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
Document document = DocumentHelper.createDocument();
Element rootElement = document.addElement("root");
Element versionElement = rootElement.addElement("version");
versionElement.setText("1.0");
Element modifiedElement = rootElement.addElement("modified");
modifiedElement.setText("2011-11-16 11:00:00");
Element seller_idElement = rootElement.addElement("seller_id");
seller_idElement.setText("公司名称");
Element seller_catsElement = rootElement.addElement("seller_cats");
Element catElement = null;
Element scid1Element = null;
Element name1Element = null;
int i=1;
while (rs.next()) {
i++;
catElement = seller_catsElement.addElement("cat");
scid1Element = catElement.addElement("scid");
scid1Element.setText(i+"");
name1Element = catElement.addElement("name");
name1Element.setText(rs.getString("name"));
}
try {
//生成文件
//XMLWriter output = new XMLWriter(new FileOutputStream(new File(path+"xml/SellerCats.xml")),format);
XMLWriter output = new XMLWriter(new FileOutputStream(new File("C:/Program Files/apache-tomcat-6.0.32/webapps/travel_platform/xml/SellerCats.xml")),format);
output.write(document);
output.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (ps != null) {
ps.close();
ps = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] argv) throws SQLException {
XmlSellerCats dom4j = new XmlSellerCats();
dom4j.executeInternal();
}
}
- cymlancy
- JVM 内存参数设置
- 如何借用SAP标准日志处理显示工具
- autoit3 ie.au3 函数之——_IEDocInsertHTML
- Hadoop-----Unrecognized option: -jvm
- 有点high啊,有木有坑爹啊
- cymlancy
- SQL SERVER 2005 sa登录失败
- latin1保存汉字导致不同的汉字被认为“相等”
- YII Framework学习教程-用YIIC快速创建YII应用-2011-11-10
- 主页面 往 子页面传值 问题(一)
- Verious结盟Elance力推“一站式组件交易服务”
- JUnit测试框架使用介绍
- 判断IP地址是否为内网IP地址
- 设置android textview行间距