public class JDBCFormatter
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JDBCFormatter.SqlColumn
Describes a column as it will be written to a table in an RDBMS.
|
| Constructor and Description |
|---|
JDBCFormatter(java.sql.Connection conn,
StarTable table)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
createJDBCTable(java.lang.String tableName,
WriteMode mode)
Writes data from this formatter's input table into the database.
|
JDBCFormatter.SqlColumn |
getColumn(int icol)
Returns the SqlColumn object describing how a given column of this
formatter's input table will be written into the RDBMS.
|
java.lang.String |
getCreateStatement(java.lang.String tableName)
Returns the text of a suitable CREATE TABLE statement.
|
java.lang.String |
getInsertStatement(java.lang.String tableName)
Returns the text of a suitable parametric statement for inserting a
row.
|
int |
getSqlType(java.lang.Class<?> clazz)
Returns an SQL type code suitable for a given class.
|
static void |
main(java.lang.String[] args)
Main method.
|
java.lang.String |
typeName(int sqlType)
Returns the name used by the connection's database to reference a
JDBC type.
|
public JDBCFormatter(java.sql.Connection conn,
StarTable table)
throws java.sql.SQLException,
java.io.IOException
conn - JDBC connectiontable - input tablejava.sql.SQLExceptionjava.io.IOExceptionpublic java.lang.String getCreateStatement(java.lang.String tableName)
tableName - name of the new SQL tablepublic java.lang.String getInsertStatement(java.lang.String tableName)
tableName - name SQL table for insertionpublic void createJDBCTable(java.lang.String tableName,
WriteMode mode)
throws java.io.IOException,
java.sql.SQLException
tableName - name of the new table to write to in the databasemode - mode for writing recordsjava.io.IOExceptionjava.sql.SQLExceptionpublic JDBCFormatter.SqlColumn getColumn(int icol)
null, it means that
column cannot, and will not, be written.icol - column index in input tablepublic int getSqlType(java.lang.Class<?> clazz)
clazz - java class of dataTypes codespublic java.lang.String typeName(int sqlType)
throws java.sql.SQLException
sqlType - type id (as per Types)java.sql.SQLExceptionpublic static void main(java.lang.String[] args)
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLException