Package edu.wisc.game.tools

## Class ExportTable

- java.lang.Object
- - edu.wisc.game.tools.ExportTable

-     public class ExportTable
      extends Object

  This is a substitute for something like this:

      select * into outfile '/var/lib/mysql-files/tmp-PlayerInfo.csv'   FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'   LINES TERMINATED BY '\n'   FROM game.PlayerInfo;

  It is to be used on machines where the MySQL server is not set up with permissions to write to any directory (i.e. @@secure_file_priv is NULL).

  Unlike most of other database-connecting tools, this class uses the plain JDBC Connection, rather than JPA. This is done so that we can send over plain SQL commands, such as "SELECT * FROM ...", and to access the ResultSet's metadata, finding out the names of the columns in the result. The point of this exercise is to be able to print the table header (column names) into the output CSV file.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ExportTable()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `doQuery​(String[] queries, File f)` | Executes a query, or several statements the last of which is a query.
    `static void` | `doQuery​(String sql, File f)` |
    `static void` | `doQuery2​(Connection conn, String[] queries, File f)` | This one just sends commands to an existing connection, without closing it
    `static void` | `main​(String[] argv)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExportTable

          public ExportTable()

  - ### Method Detail

    - #### main

          public static void main​(String[] argv)
                           throws Exception

      Throws:
        `Exception`

    - #### doQuery

          public static void doQuery​(String sql,
                                     File f)
                              throws IOException,
                                     SQLException

      Throws:
        `IOException`
        `SQLException`

    - #### doQuery

          public static void doQuery​(String[] queries,
                                     File f)
                              throws IOException,
                                     SQLException

      Executes a query, or several statements the last of which is a query. Prints out the result of the last query into a CSV file.
      Throws:
        `IOException`
        `SQLException`

    - #### doQuery2

          public static void doQuery2​(Connection conn,
                                      String[] queries,
                                      File f)
                               throws IOException,
                                      SQLException

      This one just sends commands to an existing connection, without closing it
      Throws:
        `IOException`
        `SQLException`