martin.common
Class SQL

java.lang.Object
  extended by martin.common.SQL

public class SQL
extends java.lang.Object


Constructor Summary
SQL()
           
 
Method Summary
static java.sql.Connection connectMySQL(ArgParser ap, java.util.logging.Logger logger, java.lang.String postfix)
          Creates a connection to a MySQL database, using arguments held by the ArgParser.
static MyConnection connectMySQL2(ArgParser ap, java.util.logging.Logger logger, java.lang.String postfix)
          Creates a connection to a MySQL database, using arguments held by the ArgParser.
private static java.sql.PreparedStatement createTable(java.sql.Connection conn, java.lang.String table, java.lang.String[] columnNames, java.lang.String[] types, boolean clear)
           
private static java.util.List<java.lang.String> getIndices(java.lang.String[] columns)
           
private static Tuple<java.lang.String[],int[]> guessTypes(java.io.File file, java.lang.String sep)
           
private static void index(java.sql.Connection conn, java.lang.String table, java.util.List<java.lang.String> indices)
           
static void main(java.lang.String[] args)
           
static void set(java.sql.PreparedStatement pstmt, int field, java.lang.Boolean value)
           
static void set(java.sql.PreparedStatement pstmt, int field, java.lang.Double value)
           
static void set(java.sql.PreparedStatement pstmt, int field, java.lang.Float value)
           
static void set(java.sql.PreparedStatement pstmt, int field, java.lang.Integer value)
           
static void set(java.sql.PreparedStatement pstmt, int field, java.lang.String value)
           
private static void uploadTable(java.io.File f, java.lang.String table, java.lang.String sep, java.sql.Connection conn, boolean clear, int report, java.util.logging.Logger logger)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQL

public SQL()
Method Detail

connectMySQL

public static java.sql.Connection connectMySQL(ArgParser ap,
                                               java.util.logging.Logger logger,
                                               java.lang.String postfix)
Creates a connection to a MySQL database, using arguments held by the ArgParser.

Parameters:
ap - Argument parser, holding properties "dbHost", "dbUsername", "dbPassword" and "dbSchema".
logger - Logger which is used to provide information back to the user.
postfix - if postfix != null, arguments will instead be read from dbHost-postfix, dbUsername-postfix, etc. instead.
Returns:
a connection to the database.

connectMySQL2

public static MyConnection connectMySQL2(ArgParser ap,
                                         java.util.logging.Logger logger,
                                         java.lang.String postfix)
Creates a connection to a MySQL database, using arguments held by the ArgParser.

Parameters:
ap - Argument parser, holding properties "dbHost", "dbUsername", "dbPassword" and "dbSchema".
logger - Logger which is used to provide information back to the user.
postfix - if postfix != null, arguments will instead be read from dbHost-postfix, dbUsername-postfix, etc. instead.
Returns:
A "MyConnection" object, which can be used to get a connection (but also allows reconnection).

main

public static void main(java.lang.String[] args)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

uploadTable

private static void uploadTable(java.io.File f,
                                java.lang.String table,
                                java.lang.String sep,
                                java.sql.Connection conn,
                                boolean clear,
                                int report,
                                java.util.logging.Logger logger)

index

private static void index(java.sql.Connection conn,
                          java.lang.String table,
                          java.util.List<java.lang.String> indices)

getIndices

private static java.util.List<java.lang.String> getIndices(java.lang.String[] columns)

createTable

private static java.sql.PreparedStatement createTable(java.sql.Connection conn,
                                                      java.lang.String table,
                                                      java.lang.String[] columnNames,
                                                      java.lang.String[] types,
                                                      boolean clear)

guessTypes

private static Tuple<java.lang.String[],int[]> guessTypes(java.io.File file,
                                                          java.lang.String sep)

set

public static void set(java.sql.PreparedStatement pstmt,
                       int field,
                       java.lang.Boolean value)

set

public static void set(java.sql.PreparedStatement pstmt,
                       int field,
                       java.lang.Float value)

set

public static void set(java.sql.PreparedStatement pstmt,
                       int field,
                       java.lang.Double value)

set

public static void set(java.sql.PreparedStatement pstmt,
                       int field,
                       java.lang.Integer value)

set

public static void set(java.sql.PreparedStatement pstmt,
                       int field,
                       java.lang.String value)