• <legend id='xMBEl'><style id='xMBEl'><dir id='xMBEl'><q id='xMBEl'></q></dir></style></legend>

        <i id='xMBEl'><tr id='xMBEl'><dt id='xMBEl'><q id='xMBEl'><span id='xMBEl'><b id='xMBEl'><form id='xMBEl'><ins id='xMBEl'></ins><ul id='xMBEl'></ul><sub id='xMBEl'></sub></form><legend id='xMBEl'></legend><bdo id='xMBEl'><pre id='xMBEl'><center id='xMBEl'></center></pre></bdo></b><th id='xMBEl'></th></span></q></dt></tr></i><div id='xMBEl'><tfoot id='xMBEl'></tfoot><dl id='xMBEl'><fieldset id='xMBEl'></fieldset></dl></div>

        <small id='xMBEl'></small><noframes id='xMBEl'>

      1. <tfoot id='xMBEl'></tfoot>

        • <bdo id='xMBEl'></bdo><ul id='xMBEl'></ul>

        如何使用 jdbc 中的 ResultSet.getBinaryStream() 从所有列中获取值?

        How do you get values from all columns using ResultSet.getBinaryStream() in jdbc?(如何使用 jdbc 中的 ResultSet.getBinaryStream() 从所有列中获取值?)
      2. <small id='JuCmU'></small><noframes id='JuCmU'>

                  <bdo id='JuCmU'></bdo><ul id='JuCmU'></ul>

                  <tfoot id='JuCmU'></tfoot>
                    <tbody id='JuCmU'></tbody>
                  <i id='JuCmU'><tr id='JuCmU'><dt id='JuCmU'><q id='JuCmU'><span id='JuCmU'><b id='JuCmU'><form id='JuCmU'><ins id='JuCmU'></ins><ul id='JuCmU'></ul><sub id='JuCmU'></sub></form><legend id='JuCmU'></legend><bdo id='JuCmU'><pre id='JuCmU'><center id='JuCmU'></center></pre></bdo></b><th id='JuCmU'></th></span></q></dt></tr></i><div id='JuCmU'><tfoot id='JuCmU'></tfoot><dl id='JuCmU'><fieldset id='JuCmU'></fieldset></dl></div>
                  <legend id='JuCmU'><style id='JuCmU'><dir id='JuCmU'><q id='JuCmU'></q></dir></style></legend>

                  本文介绍了如何使用 jdbc 中的 ResultSet.getBinaryStream() 从所有列中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何使用 jdbc 将整个表写入平面文件(文本文件)?到目前为止,我尝试了以下方法:

                  How do I to write an entire table to a flat file (text file) using jdbc? So far I've attempted the following:

                  Statement statement = connection.createStatement();
                     ResultSet result = statement.executeQuery("SELECT * FROM tablename");
                     BufferedInputStream buffer;
                     FileOutputStream out = new FileOutputStream("flatfile.txt");
                     while(result.next() )
                     {
                        buffer =  new BufferedInputStream(result.getBinaryStream("????") );
                        byte[] buf = new byte[4 * 1024]; //4K buffer
                        int len;
                        while( (len = buffer.read(buf, 0, buf.length) ) != -1 )
                        {
                            out.write(buf, 0, len );
                        }
                     }
                     out.close();
                  

                  ???"只是我的占位符.我被困在作为参数传递的内容上.

                  "????" is just my placeholder. I am stuck on what to pass in as an argument.

                  推荐答案

                  您可以使用下面的代码从表中获取所有列名和整个数据.writeToFile 方法将包含写入文件的逻辑(如果这还不够明显:))

                  You can get all the column names and the entire data from your table using the code below. writeToFile method will contain the logic to writing to file (if that was not obvious enough :) )

                      ResultSetMetaData metadata = rs.getMetaData();
                      int columnCount = metadata.getColumnCount();    
                      for (int i = 1; i <= columnCount; i++) {
                          writeToFile(metadata.getColumnName(i) + ", ");      
                      }
                      System.out.println();
                      while (rs.next()) {
                          String row = "";
                          for (int i = 1; i <= columnCount; i++) {
                              row += rs.getString(i) + ", ";          
                          }
                          System.out.println();
                          writeToFile(row);
                  
                      }
                  

                  这篇关于如何使用 jdbc 中的 ResultSet.getBinaryStream() 从所有列中获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                  Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                  How to convert Integer to int?(如何将整数转换为整数?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                  Inconsistent behavior on java#39;s ==(java的行为不一致==)
                  Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)

                  <tfoot id='eHs9H'></tfoot>
                  <i id='eHs9H'><tr id='eHs9H'><dt id='eHs9H'><q id='eHs9H'><span id='eHs9H'><b id='eHs9H'><form id='eHs9H'><ins id='eHs9H'></ins><ul id='eHs9H'></ul><sub id='eHs9H'></sub></form><legend id='eHs9H'></legend><bdo id='eHs9H'><pre id='eHs9H'><center id='eHs9H'></center></pre></bdo></b><th id='eHs9H'></th></span></q></dt></tr></i><div id='eHs9H'><tfoot id='eHs9H'></tfoot><dl id='eHs9H'><fieldset id='eHs9H'></fieldset></dl></div>
                      • <bdo id='eHs9H'></bdo><ul id='eHs9H'></ul>
                      • <legend id='eHs9H'><style id='eHs9H'><dir id='eHs9H'><q id='eHs9H'></q></dir></style></legend>

                        • <small id='eHs9H'></small><noframes id='eHs9H'>

                            <tbody id='eHs9H'></tbody>