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<T> 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 void |
execSimpleStatement(java.sql.Connection conn, java.lang.String sqlStatement)
Executes the specified SQL statement using the specified connection.
|
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.
|
static void |
validateSQLName(java.sql.Connection conn, java.lang.String sqlName)
Validates a simple SQL name using database procedure DBMS_ASSERT.simple_sql_name.
|
static java.lang.Boolean[] |
validateSQLNames(java.sql.Connection conn, java.lang.String[] sqlNames)
Validates the list of given sql names checking that all of them are qualified sql names.
|
public static void execSimpleStatement(java.sql.Connection conn, java.lang.String sqlStatement) throws java.sql.SQLException
conn
- connectionsqlStatement
- SQL statement to be executed.java.sql.SQLException
- if an SQL exception is thrownpublic 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 void validateSQLName(java.sql.Connection conn, java.lang.String sqlName) throws java.sql.SQLException
conn
- connectionsqlName
- SQL name to be validatedjava.sql.SQLException
- if an SQL exception is thrownpublic static java.lang.Boolean[] validateSQLNames(java.sql.Connection conn, java.lang.String[] sqlNames) throws java.sql.SQLException
conn
- Database connectionsqlNames
- list of names to validatejava.sql.SQLException
- If an error occurs while executing the sql validationpublic 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<T> 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