public class ConnectedStatementsWriter extends AbstractStatementsWriter
StatementsWriter which writes the SQL statements directly to a database connection.AbstractStatementsWriter.AbstractTableStatement, AbstractStatementsWriter.InsertStatement, AbstractStatementsWriter.PlainStatement, AbstractStatementsWriter.UpdateStatement| Modifier and Type | Field and Description |
|---|---|
static String |
DATABASE_DRIVER_KEY
Name of the setting that contains the connection driver class, if the writer create the a connection himself.
|
static String |
DATABASE_PASSWORD_KEY
Name of the setting that contains the connection password, if the writer create the a connection himself.
|
static String |
DATABASE_URL_KEY
Name of the setting that contains the connection URL, if the writer create the a connection himself.
|
static String |
DATABASE_USER_KEY
Name of the setting that contains the connection user, if the writer create the a connection himself.
|
static String |
LOG_STATEMENTS_KEY
Name of the setting which turns logging of statements on or off.
|
static String |
MAX_BATCH_SIZE_KEY
Name of the setting which controls the maximum size of generated batches.
|
| Constructor and Description |
|---|
ConnectedStatementsWriter(Connection connection,
GeneratorContext context)
Creates a new StatementsWriter that writes to a database connection.
|
ConnectedStatementsWriter(GeneratorContext context)
Creates a new StatementsWriter that writes to a database connection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
TableStatement |
createInsertStatement(GeneratorDialect dialect,
GeneratorTable table)
Creates a container for a dedicated "insert into table" statement.
|
void |
flush()
Flushes any open statements.
|
Connection |
getConnection()
The database connection that was used when creating this generator.
|
long |
getStatementsCount()
The count of statements that we have executed up to now.
|
void |
writePlainStatement(GeneratorDialect dialect,
String sql)
Writes a plain SQL statement.
|
void |
writeStatement(EntityStatement stmt)
Writes the given statement to a file or database.
|
createPlainStatement, createUpdateStatement, writeComment, writeSectionSeparatorclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waittruncateTablespublic static final String DATABASE_DRIVER_KEY
public static final String DATABASE_URL_KEY
public static final String DATABASE_USER_KEY
public static final String DATABASE_PASSWORD_KEY
public static final String MAX_BATCH_SIZE_KEY
public static final String LOG_STATEMENTS_KEY
public ConnectedStatementsWriter(Connection connection, GeneratorContext context) throws SQLException
connection - the database connectioncontext - contains the indices for initializationSQLException - if the connection is invalidpublic ConnectedStatementsWriter(GeneratorContext context) throws SQLException
context - contains the properties and indices for initializationSQLException - if the connection is invalidpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class AbstractStatementsWriterIOExceptionpublic TableStatement createInsertStatement(GeneratorDialect dialect, GeneratorTable table)
StatementsWritercreateInsertStatement in interface StatementsWritercreateInsertStatement in class AbstractStatementsWriterdialect - the current database dialecttable - the name of the tablepublic void flush()
throws IOException
StatementsWriterflush in interface StatementsWriterflush in class AbstractStatementsWriterIOException - if the target throws an exceptionpublic void writePlainStatement(GeneratorDialect dialect, String sql) throws IOException
StatementsWriterwriteStatement(createPlainStatement(sql), dialect).dialect - the current database dialectsql - the content of the SQL statementIOException - if the file or database throws an exceptionpublic void writeStatement(EntityStatement stmt) throws IOException
StatementsWriterstmt - contains the values to writeIOException - if the file or database throws an exception@Generated(value="lombok") public Connection getConnection()
@Generated(value="lombok") public long getStatementsCount()
Copyright © 2020 fastnate.org. All rights reserved.