public class JDBCUtils
extends java.lang.Object
Constructor and Description |
---|
JDBCUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> java.lang.String |
createInSQLExpression(java.lang.String column,
java.util.Collection<java.lang.Long> elements,
boolean stringType)
Creates a SQL IN expression of the form "column IN (elements)" taking care of the maximum number of elements supported in an in expression (1000).
|
static void |
createSequence(java.sql.Connection conn,
java.lang.String sequenceName,
long initialValue,
int increment)
Creates a sequence.
|
static java.lang.String |
createSequenceForTable(java.sql.Connection conn,
java.lang.String tableName,
long initialValue,
int increment)
Creates a sequence for a table, the name of the sequence will be the concatenation of the table name and _ID_SEQ.
|
static void |
deleteTable(java.sql.Connection conn,
java.lang.String tableName)
Drops the table.
|
static java.lang.Object |
getResultSetColumnValue(java.sql.ResultSet resultSet,
java.lang.String columnName,
NFEAttributeType expectedType)
Gets the resultSet column value of the specified column, the resultSet will get the value depending on the type.
|
static long |
getSequenceNextValue(java.sql.Connection conn,
java.lang.String seqName)
Retrieves the next value from a given sequence name.
|
static long[] |
getSequenceNextValues(java.sql.Connection conn,
java.lang.String seqName,
int valuesCount)
Retrieves the next values from a given sequence name.
|
static boolean |
tableExists(java.sql.Connection conn,
java.lang.String tableName)
Returns true if a table with the specified name already exists, false otherwise.
|
public static long getSequenceNextValue(java.sql.Connection conn, java.lang.String seqName) throws NFEIOException, java.sql.SQLException
conn
- connectionseqName
- sequence Namejava.sql.SQLException
- if an SQL exception is thrownNFEIOException
public static long[] getSequenceNextValues(java.sql.Connection conn, java.lang.String seqName, int valuesCount) throws java.sql.SQLException
conn
- connectionseqName
- sequence NamevaluesCount
- number of values to retrievejava.sql.SQLException
- if an SQL exception is thrownpublic static java.lang.String createSequenceForTable(java.sql.Connection conn, java.lang.String tableName, long initialValue, int increment) throws NFEIOException, java.sql.SQLException
conn
- connectiontableName
- table nameinitialValue
- initial value of the sequenceincrement
- sequence incrementjava.sql.SQLException
- if an SQL exception is thrownNFEIOException
public static <T> java.lang.String createInSQLExpression(java.lang.String column, java.util.Collection<java.lang.Long> elements, boolean stringType)
column
- column nameelements
- elements to add to SQL IN expressionstringType
- true if the elements in the collection are strings false otherwise. If the elements are strings the quotes will be addedpublic static java.lang.Object getResultSetColumnValue(java.sql.ResultSet resultSet, java.lang.String columnName, NFEAttributeType expectedType) throws java.sql.SQLException
resultSet
- resultSetcolumnName
- columnexpectedType
- expected typejava.sql.SQLException
- if an SQL exception is thrownpublic static void createSequence(java.sql.Connection conn, java.lang.String sequenceName, long initialValue, int increment) throws NFEIOException, java.sql.SQLException
conn
- connectionsequenceName
- name of the sequenceinitialValue
- initial value of the sequenceincrement
- sequence incrementjava.sql.SQLException
- if an SQL exception is thrownNFEIOException
public static boolean tableExists(java.sql.Connection conn, java.lang.String tableName) throws java.sql.SQLException
conn
- connectiontableName
- table namejava.sql.SQLException
- if an SQL exception is thrown.public static void deleteTable(java.sql.Connection conn, java.lang.String tableName) throws NFEIOException, java.sql.SQLException
conn
- connectiontableName
- name of the table to dropjava.sql.SQLException
- if an SQL exception is thrown.NFEIOException