future2012lg

博客园 首页 新随笔 联系 订阅 管理

package JdbcDb;

import java.io.FileWriter;
import java.io.IOException;
import java.sql.*;

public class TestCongfc {

 /**
  * @param args
  */
 public static void main(String[] args) {
  ResultSet rs = null;
  Statement stmt = null;
  Connection conn = null;
  try {
   Class.forName("oracle.jdbc.driver.OracleDriver");
   conn = DriverManager.getConnection(
     "jdbc:oracle:thin:@127.0.0.1:1521:GFCDA", "dbusrg01",
     "future");
   stmt = conn.createStatement();
   rs = stmt.executeQuery("select * from dpee_csv  ");
   try {
    FileWriter fw = new FileWriter("C:\\helloworld.csv");
    while (rs.next()) {
     // System.out.println(rs.getString("RECORDTYPE"));
     // fw.write(rs.getString("ROWHD")+"|"+rs.getString("RECORDTYPE")+"|"+rs.getString("MODAY")+"\r\n");
     fw.write(rs.getString("ROWHD")+"|"+
       rs.getString("RECORDTYPE")+"|"+
       (rs.getString("PRODUCTCODE")==null?"":rs.getString("PRODUCTCODE"))+"|"+
       (rs.getString("SHIPMENTDATE")==null?"":rs.getString("SHIPMENTDATE"))+"|"+
       (rs.getString("SUMWEIGHT")==null?"":rs.getString("SUMWEIGHT"))+"|"+
       (rs.getString("SUMVOLUME")==null?"":rs.getString("SUMVOLUME"))+"|"+
       (rs.getString("INSUREDVALUE")==null?"":rs.getString("INSUREDVALUE"))+"|"+
       (rs.getString("INSURANCECURRENCY")==null?"":rs.getString("INSURANCECURRENCY"))+"|"+
       (rs.getString("SHIPMENTREFERENCE")==null?"":rs.getString("SHIPMENTREFERENCE"))+"|"+
       (rs.getString("STR1")==null?"":rs.getString("STR1"))+"|"+
       (rs.getString("SENDERREFERENCE")==null?"":rs.getString("SENDERREFERENCE"))+"|"+
       (rs.getString("HDFKFW")==null?"":rs.getString("HDFKFW"))+"|"+
       (rs.getString("HDFKJZ")==null?"":rs.getString("HDFKJZ"))+"|"+
       (rs.getString("HDFKBX")==null?"":rs.getString("HDFKBX"))+"|"+
       (rs.getString("HDFKLX")==null?"":rs.getString("HDFKLX"))+"|"+
       (rs.getString("FREEMAIL")==null?"":rs.getString("FREEMAIL"))+"|"+
       (rs.getString("SERVICEEXPRESS10")==null?"":rs.getString("SERVICEEXPRESS10"))+"|"+
       (rs.getString("SERVICEEXPRESS12")==null?"":rs.getString("SERVICEEXPRESS12"))+"|"+
       (rs.getString("SERVICEEXPRESS9")==null?"":rs.getString("SERVICEEXPRESS9"))+"|"+
       (rs.getString("WXPYSFW")==null?"":rs.getString("WXPYSFW"))+"|"+
       (rs.getString("HIGHSERVICE")==null?"":rs.getString("HIGHSERVICE"))+"|"+
       (rs.getString("BULKYSERVICE")==null?"":rs.getString("BULKYSERVICE"))+"|"+
       (rs.getString("BULKYTYPE")==null?"":rs.getString("BULKYTYPE"))+"|"+
       (rs.getString("NIGHTSERVICE")==null?"":rs.getString("NIGHTSERVICE"))+"|"+
       (rs.getString("RECEIVEDATE")==null?"":rs.getString("RECEIVEDATE"))+"|"+
       (rs.getString("VALUEGOODS")==null?"":rs.getString("VALUEGOODS"))+"|"+
       (rs.getString("VALUEGOODSBX")==null?"":rs.getString("VALUEGOODSBX"))+"|"+
       (rs.getString("BULKYGOODSOLD")==null?"":rs.getString("BULKYGOODSOLD"))+"|"+
       (rs.getString("HAZARDOUSFL")==null?"":rs.getString("HAZARDOUSFL"))+"|"+
       (rs.getString("COMMERCIALTERMS")==null?"":rs.getString("COMMERCIALTERMS"))+"|"+
       (rs.getString("SPECIALYHTYPES")==null?"":rs.getString("SPECIALYHTYPES"))+"|"+
       (rs.getString("RECIVERYFYW")==null?"":rs.getString("RECIVERYFYW"))+"|"+
       (rs.getString("STARDY")==null?"":rs.getString("STARDY"))+"|"+
       (rs.getString("PARTICIPATION")==null?"":rs.getString("PARTICIPATION"))+"|"+
       (rs.getString("WPZJHFXFW")==null?"":rs.getString("WPZJHFXFW"))+"|"+
       (rs.getString("GDTIMEJF")==null?"":rs.getString("GDTIMEJF"))+"|"+
       (rs.getString("SPECIFICDATEFW")==null?"":rs.getString("SPECIFICDATEFW"))+"|"+
       (rs.getString("SPECIALEARLY")==null?"":rs.getString("SPECIALEARLY"))+"|"+
       (rs.getString("SERVICEAFTERNOON")==null?"":rs.getString("SERVICEAFTERNOON"))+"|"+
       (rs.getString("SERVICEEVENING")==null?"":rs.getString("SERVICEEVENING"))+"|"+
       (rs.getString("SERVICESUNDAY")==null?"":rs.getString("SERVICESUNDAY"))+"|"+
       (rs.getString("SERVICEEPN")==null?"":rs.getString("SERVICEEPN"))+"|"+
       (rs.getString("DDKDHFW")==null?"":rs.getString("DDKDHFW"))+"|"+
       (rs.getString("SERVICESINGLE")==null?"":rs.getString("SERVICESINGLE"))+"|"+
       (rs.getString("SERVICEADVICE")==null?"":rs.getString("SERVICEADVICE"))+"|"+
       (rs.getString("ZLSJFW")==null?"":rs.getString("ZLSJFW"))+"|"+
       (rs.getString("YCSJFW")==null?"":rs.getString("YCSJFW"))+"|"+
       (rs.getString("JHZMFW")==null?"":rs.getString("JHZMFW"))+"|"+
       (rs.getString("NOFKFWLX")==null?"":rs.getString("NOFKFWLX"))+"|"+
       (rs.getString("WYFKJFS")==null?"":rs.getString("WYFKJFS"))+"|"+
       (rs.getString("YFSLFL")==null?"":rs.getString("YFSLFL"))+"|"+
       (rs.getString("KHSJFW")==null?"":rs.getString("KHSJFW"))+"|"+
       (rs.getString("SERVICEECONOMY")==null?"":rs.getString("SERVICEECONOMY"))+"|"+
       (rs.getString("SERVICEPREMIUM")==null?"":rs.getString("SERVICEPREMIUM"))+"|"+
       (rs.getString("KSBGYSFW")==null?"":rs.getString("KSBGYSFW"))+"|"+
       (rs.getString("WITHOUTTRANSPORT")==null?"":rs.getString("WITHOUTTRANSPORT"))+"|"+
       (rs.getString("SERVICEAMOUNT")==null?"":rs.getString("SERVICEAMOUNT"))+"|"+
       (rs.getString("SERVICESENDERS")==null?"":rs.getString("SERVICESENDERS"))+"|"+
       (rs.getString("SERVICESENDERSLX")==null?"":rs.getString("SERVICESENDERSLX"))+"|"+
       (rs.getString("SENDERSINSTRUCTIONS")==null?"":rs.getString("SENDERSINSTRUCTIONS"))+"|"+
       (rs.getString("STR2")==null?"":rs.getString("STR2"))+"|"+
       (rs.getString("STR3")==null?"":rs.getString("STR3"))+"|"+
       (rs.getString("STR4")==null?"":rs.getString("STR4"))+"|"+
       (rs.getString("STR5")==null?"":rs.getString("STR5"))+"|"+
       (rs.getString("STR6")==null?"":rs.getString("STR6"))+"|"+
       (rs.getString("STR7")==null?"":rs.getString("STR7"))+"|"+
       (rs.getString("STR8")==null?"":rs.getString("STR8"))+"|"+
       (rs.getString("STR9")==null?"":rs.getString("STR9"))+"|"+
       (rs.getString("STR10")==null?"":rs.getString("STR10"))+"|"+
       (rs.getString("STR11")==null?"":rs.getString("STR11"))+"|"+
       (rs.getString("STR12")==null?"":rs.getString("STR12"))+"|"+
       (rs.getString("STR13")==null?"":rs.getString("STR13"))+"|"+
       (rs.getString("SERVICEGOGREEN")==null?"":rs.getString("SERVICEGOGREEN"))+"|"+
       (rs.getString("SERVICESMSAVISO")==null?"":rs.getString("SERVICESMSAVISO"))+"|"+
       (rs.getString("SERVICEEXTRA")==null?"":rs.getString("SERVICEEXTRA"))+"|"+
       (rs.getString("SERVICEPROACTIVE")==null?"":rs.getString("SERVICEPROACTIVE"))+"|"+
       (rs.getString("SERVICEAGESF")==null?"":rs.getString("SERVICEAGESF"))+"|"+
       (rs.getString("SERVICEBYPASS")==null?"":rs.getString("SERVICEBYPASS"))+"|"+
       (rs.getString("SERVICEDIRECTINJECTION")==null?"":rs.getString("SERVICEDIRECTINJECTION"))+"|"+
       (rs.getString("SERVICELW")==null?"":rs.getString("SERVICELW"))+"|"+
       (rs.getString("STR14")==null?"":rs.getString("STR14"))+"|"+
       (rs.getString("SERVICEEPNFL")==null?"":rs.getString("SERVICEEPNFL"))+"\r\n");
    }
    fw.close();
   } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }

  } catch (ClassNotFoundException e) {
   e.printStackTrace();
  } catch (SQLException e) {
   e.printStackTrace();
  } finally {
   try {
    if (rs != null) {
     rs.close();
     rs = null;
    }
    if (stmt != null) {
     stmt.close();
     stmt = null;
    }
    if (conn != null) {
     conn.close();
     conn = null;
    }
   } catch (SQLException e) {
    e.printStackTrace();
   }
  }

 }
}

posted on 2012-11-14 09:21  future2012lg  阅读(1042)  评论(0编辑  收藏  举报