Class JDBCUtils
- java.lang.Object
-
- oracle.spatial.network.nfe.io.jdbc.JDBCUtils
-
public class JDBCUtils extends java.lang.ObjectUtilities used by NFE to execute queries and perform common operations.
-
-
Constructor Summary
Constructors Constructor Description JDBCUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.lang.StringcreateInSQLExpression(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 voidcreateSequence(java.sql.Connection conn, java.lang.String sequenceName, long initialValue, int increment)Creates a sequence.static java.lang.StringcreateSequenceForTable(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 voiddeleteTable(java.sql.Connection conn, java.lang.String tableName)Drops the table.static java.lang.ObjectgetResultSetColumnValue(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 longgetSequenceNextValue(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 booleantableExists(java.sql.Connection conn, java.lang.String tableName)Returns true if a table with the specified name already exists, false otherwise.
-
-
-
Method Detail
-
getSequenceNextValue
public static long getSequenceNextValue(java.sql.Connection conn, java.lang.String seqName) throws NFEIOException, java.sql.SQLExceptionRetrieves the next value from a given sequence name.- Parameters:
conn- connectionseqName- sequence Name- Returns:
- next sequence value
- Throws:
java.sql.SQLException- if an SQL exception is thrownNFEIOException
-
getSequenceNextValues
public static long[] getSequenceNextValues(java.sql.Connection conn, java.lang.String seqName, int valuesCount) throws java.sql.SQLExceptionRetrieves the next values from a given sequence name.- Parameters:
conn- connectionseqName- sequence NamevaluesCount- number of values to retrieve- Returns:
- next sequence values
- Throws:
java.sql.SQLException- if an SQL exception is thrown
-
createSequenceForTable
public static java.lang.String createSequenceForTable(java.sql.Connection conn, java.lang.String tableName, long initialValue, int increment) throws NFEIOException, java.sql.SQLExceptionCreates a sequence for a table, the name of the sequence will be the concatenation of the table name and _ID_SEQ.- Parameters:
conn- connectiontableName- table nameinitialValue- initial value of the sequenceincrement- sequence increment- Returns:
- sequence name
- Throws:
java.sql.SQLException- if an SQL exception is thrownNFEIOException
-
createInSQLExpression
public 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).- Parameters:
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 added- Returns:
- one IN expression of the form "column IN (elements)" or two or more IN expressions of the form "column IN (elements 0 ....N ) OR column IN (elements N....M) .... OR column IN (elements X.....Y)"
-
getResultSetColumnValue
public static java.lang.Object getResultSetColumnValue(java.sql.ResultSet resultSet, java.lang.String columnName, NFEAttributeType expectedType) throws java.sql.SQLExceptionGets the resultSet column value of the specified column, the resultSet will get the value depending on the type.- Parameters:
resultSet- resultSetcolumnName- columnexpectedType- expected type- Returns:
- column value
- Throws:
java.sql.SQLException- if an SQL exception is thrown
-
createSequence
public static void createSequence(java.sql.Connection conn, java.lang.String sequenceName, long initialValue, int increment) throws NFEIOException, java.sql.SQLExceptionCreates a sequence.- Parameters:
conn- connectionsequenceName- name of the sequenceinitialValue- initial value of the sequenceincrement- sequence increment- Throws:
java.sql.SQLException- if an SQL exception is thrownNFEIOException
-
tableExists
public static boolean tableExists(java.sql.Connection conn, java.lang.String tableName) throws java.sql.SQLExceptionReturns true if a table with the specified name already exists, false otherwise.- Parameters:
conn- connectiontableName- table name- Returns:
- true if a table with the specified name already exists, false otherwise
- Throws:
java.sql.SQLException- if an SQL exception is thrown.
-
deleteTable
public static void deleteTable(java.sql.Connection conn, java.lang.String tableName) throws NFEIOException, java.sql.SQLExceptionDrops the table.- Parameters:
conn- connectiontableName- name of the table to drop- Throws:
java.sql.SQLException- if an SQL exception is thrown.NFEIOException
-
-