第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將 SQL Server 打印到 CSV 的 JAVA 代碼返回數據不完整

將 SQL Server 打印到 CSV 的 JAVA 代碼返回數據不完整

ITMISS 2021-07-07 21:42:06
我有一個 JAVA 代碼可以將 SQL Server 表輸出到 CSV。打印在中間停止,我只得到部分數據作為 CSV 輸出。在我的代碼下面。public class SQLServerConnection {    public static void main(String[] args) throws IOException, SQLException {        // TODO Auto-generated method stub        Connection conn = null;        SQLConnection cnn = new SQLConnection();        FileWriter fw = new FileWriter(cnn.fileName);        try {conn = DriverManager.getConnection(cnn.dbURL);        if (conn != null) {            DatabaseMetaData dm = (DatabaseMetaData) conn.getMetaData();        }        } catch (SQLException ex) {            ex.printStackTrace();        }         String sql = String.format(cnn.Query);        assert conn != null;        PreparedStatement preStatement;        preStatement = conn.prepareStatement(sql);        ResultSet result = preStatement.executeQuery();        ResultSetMetaData rmsd = result.getMetaData();        int Columncount = rmsd.getColumnCount();      //Get the column name and print the column name        for (int iterator=1; iterator<= Columncount; iterator++) {            fw.append(rmsd.getColumnName(iterator)+",");        }        fw.append('\n');         while(result.next()){            try {                for (int jterator=1; jterator<=Columncount; jterator++){                    fw.append(result.getString(jterator));                    fw.append(',');                }                fw.append('\n');             } catch (SQLException e)            {                e.printStackTrace();            }}        conn.close();    }}DB 和 Excel 參數的類public class SQLConnection {    public String ServerName = "Server1";    public String DBName = "DB1";    public String FileLoc = "Location of the file";    public String dbURL = "jdbc:sqlserver://"+ServerName+";databaseName="+DBName+";integratedSecurity=true";    public String Query = "SELECT * from [scdHSBCHK]";    public String fileName = (FileLoc + DBName +"_QueryResult.csv"); }實際的 db 返回 57 條記錄,但 csv 僅返回 29 條。我嘗試使用不同的 db 名稱以及相同的問題。當我在程序窗口中輸出結果時,數據顯示正確。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 235 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號