逸者

          在java中使用CsvDriver讀取csv文件

          ??????? csv文件格式是用的比較多的,前幾天在網上找到一個驅動可以把這種格式的文件當作數據庫一樣讀取。
          操作步驟如下:
          第一、下載驅動程序http://sourceforge.net/projects/csvjdbc
          第二、把csvjdbc.jar文件放到classpath路徑中去。
          第三、例子如下:
          ?
          import java.sql.*;
          import org.relique.jdbc.csv.CsvDriver;
          public class JdbcCsv
          {
          public static void main(String[] args)
          {
          try
          {
          // load the driver into memory
          Class.forName("org.relique.jdbc.csv.CsvDriver");
          // create a connection. The first command line parameter is assumed to
          // be the directory in which the .csv files are held
          Connection conn = DriverManager.getConnection("jdbc:relique:csv:E:\\fund\\test\\");
          // create a Statement object to execute the query with
          Statement stmt = conn.createStatement();
          // Select the ID and NAME columns from sample.csv
          ResultSet results = stmt.executeQuery("SELECT djwd,銀行 from czcg");
          // dump out the results
          while (results.next())
          {
          System.out.println("djwd= " + results.getString("djwd") + " 銀行= " + results.getString("銀行"));
          }
          // clean up
          results.close();
          stmt.close();
          conn.close();
          }
          catch(Exception e)
          {
          System.out.println("Oops-> " + e);
          }
          }
          }

          posted on 2006-07-28 08:55 飄逸者 閱讀(2008) 評論(2)  編輯  收藏

          評論

          # re: 在java中使用CsvDriver讀取csv文件 2007-08-14 16:40 初心者

          十分感謝  回復  更多評論   

          # re: 在java中使用CsvDriver讀取csv文件 2007-08-31 09:15 GRAND

          @初心者
          挺好的,謝謝  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          <2007年8月>
          2930311234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆檔案

          搜索

          最新評論

          主站蜘蛛池模板: 商城县| 华阴市| 白山市| 达日县| 若羌县| 广东省| 莱阳市| 阳高县| 邯郸县| 东阿县| 碌曲县| 神池县| 沙田区| 桦川县| 东平县| 佛山市| 四川省| 贵南县| 两当县| 额敏县| 麟游县| 纳雍县| 隆子县| 泽普县| 文山县| 贺州市| 金寨县| 北辰区| 稻城县| 常山县| 门源| 梓潼县| 太谷县| 都江堰市| 东阿县| 宜川县| 女性| 英山县| 府谷县| 伊通| 法库县|