Skip navigation links

Oracle© Data Integrator Data Services Java API Reference
11g Release 1 (11.1.1.5.0)

E17062-02


oracle.odi.dataservices.fwk
Class Utils

java.lang.Object
  extended by oracle.odi.dataservices.fwk.Utils


public class Utils
extends java.lang.Object

A utility class that contains helpful methods for developing Service Knowledge Modules.


Constructor Summary
Utils()
           

 

Method Summary
static java.lang.String buildQuestionMarksString(int pParametersCount)
          Returns a String containing pParametersCount question marks separated by commas.
static java.lang.String concatStrings(java.util.List pStrings, java.lang.String pPrefix, java.lang.String pSuffix, java.lang.String pSeparator)
          Returns a String containing the input strings concatenated together..
static java.lang.String createDeleteQuery(java.lang.String pFullyQualifiedTableName, java.lang.String pWhereClause)
          Returns a String containing a SQL DELETE statement with a WHERE clause for a given table.
static java.lang.String createInsertQuery(java.util.List pColumnsToInsert, java.lang.String pFullyQualifiedTableName)
          Returns a String containing a SQL INSERT statement for a given table with a list of columns to insert into.
static java.lang.String createSelectQuery(java.util.List pColumnsToSelect, java.lang.String pFullyQualifiedTableName, java.lang.String pWhereClause, java.lang.String pOrderByClause)
          Returns a String containing a SQL SELECT query for the given table, list of columns, WHERE clause and ORDER BY clause.
static java.lang.String createUpdateQuery(java.util.List pColumnsToUpdate, java.lang.String pFullyQualifiedTableName, java.lang.String pWhereClause)
          Returns a String containing a SQL UPDATE query for a given table with a list of columns to update and a given WHERE clause.
static java.lang.String createWhereClause(QueryFilter pQueryFilter)
          Returns a String containing a SQL WHERE clause generated from a QueryFilter.
static java.lang.String createWhereClause(UpdateDeleteFilter pUpdateDeleteFilter)
          Returns a String containing a SQL WHERE clause generated from a UpdateDeleteFilter.
static java.sql.Connection getConnectionFromDataSource(java.lang.String pDataSourceName, boolean pAutoCommit)
          Returns a JDBC Connection created from the local JNDI datasource called pDataSourceName.
static void setParameters(ColumnsMeta pColumnsMeta, java.sql.PreparedStatement pStatement, ManagedEntity pSourceManagedEntity, java.util.List pColsToSet)
          Sets the parameters of a JDBC PreparedStatement using values from a ManagedEntity.
static void setParameters(ColumnsMeta pColumnsMeta, java.sql.PreparedStatement pStatement, ManagedEntity pSourceManagedEntity, java.util.List pColsToSet, int pFirstParameterIdx)
          Sets the parameters of a JDBC PreparedStatement using values from a ManagedEntity, starting with the given parameter number.
For each column name in the pColsToSet list, the value from the matching column in pSourceManagedEntity is set to each parameter in the pStatement, starting at parameter number pFirstParameterIdx.

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

Utils

public Utils()

Method Detail

getConnectionFromDataSource

public static java.sql.Connection getConnectionFromDataSource(java.lang.String pDataSourceName,
                                                              boolean pAutoCommit)
                                                       throws DataServiceException
Returns a JDBC Connection created from the local JNDI datasource called pDataSourceName. The datasource must be defined as a local datasource in the application server executing the web service.
Parameters:
pDataSourceName - JNDI datasource name
pAutoCommit - autocommit mode for the connection. True for Autocommit.
Returns:
JDBC Connection
Throws:
DataServiceException - if an error occurs while retrieving the datasource or creating the connection

concatStrings

public static java.lang.String concatStrings(java.util.List pStrings,
                                             java.lang.String pPrefix,
                                             java.lang.String pSuffix,
                                             java.lang.String pSeparator)
Returns a String containing the input strings concatenated together.. Each item of the list is prefixed by pPrefix and suffixed by pSuffix. The strings are separated by pSeparator.
For example:
Utils.concatStrings(Arrays.asList(new String[]{"a", "b", "c"}, null, null, ", ")
returns "a, b, c"
Utils.concatStrings(Arrays.asList(new String[]{"a", "b", "c"}, null, " AND ", "=?")
returns "a=? AND b=? AND c=?"
Parameters:
pStrings - list of string objects to concatenate
pPrefix - string to add before each item
pSuffix - string to add after each item
pSeparator - string separator
Returns:
the concatenated string

buildQuestionMarksString

public static java.lang.String buildQuestionMarksString(int pParametersCount)
Returns a String containing pParametersCount question marks separated by commas. For example, Utils.buildQuestionMarksString(3) returns "?, ?, ?"
Parameters:
pParametersCount - number of question marks in the list
Returns:
String containing a comma-separated list of question marks

setParameters

public static void setParameters(ColumnsMeta pColumnsMeta,
                                 java.sql.PreparedStatement pStatement,
                                 ManagedEntity pSourceManagedEntity,
                                 java.util.List pColsToSet,
                                 int pFirstParameterIdx)
                          throws java.sql.SQLException
Sets the parameters of a JDBC PreparedStatement using values from a ManagedEntity, starting with the given parameter number.
For each column name in the pColsToSet list, the value from the matching column in pSourceManagedEntity is set to each parameter in the pStatement, starting at parameter number pFirstParameterIdx. The JDBC type for the parameters are taken from the ColumnsMeta object.
Parameters:
pColumnsMeta - ColumnsMeta object containing the columns' JDBC data types
pStatement - PreparedStatement with parameters to be set
pSourceManagedEntity - ManagedEntity containing the values to set
pColsToSet - list of column names to set
pFirstParameterIdx - position of the first parameter in the PreparedStatement to set. Note that JDBC parameters indexes start at position 1.
Throws:
java.sql.SQLException - thrown if an error occurs while setting the parameter

setParameters

public static void setParameters(ColumnsMeta pColumnsMeta,
                                 java.sql.PreparedStatement pStatement,
                                 ManagedEntity pSourceManagedEntity,
                                 java.util.List pColsToSet)
                          throws java.sql.SQLException
Sets the parameters of a JDBC PreparedStatement using values from a ManagedEntity. This method is equivalent to a call to setParameters with pFirstParametersIdx equals to 1.
Parameters:
pColumnsMeta - ColumnsMeta object containing the columns' JDBC data types
pStatement - PreparedStatement with parameters to be set
pSourceManagedEntity - ManagedEntity containing the values to set
pColsToSet - list of column names to set
Throws:
java.sql.SQLException - thrown if an error occurs while setting the parameter

createSelectQuery

public static java.lang.String createSelectQuery(java.util.List pColumnsToSelect,
                                                 java.lang.String pFullyQualifiedTableName,
                                                 java.lang.String pWhereClause,
                                                 java.lang.String pOrderByClause)
                                          throws DataServiceException
Returns a String containing a SQL SELECT query for the given table, list of columns, WHERE clause and ORDER BY clause.
Parameters:
pColumnsToSelect - list of column names to retrieve in the SELECT statement
pFullyQualifiedTableName - fully qualified name of the table on which the operation is carried out
pWhereClause - SQL WHERE Clause for filtering data from the table. This clause should not include the WHERE keyword. If it is not specified, the clause will not be generated in the query
pOrderByClause - SQL ORDER BY Clause for ordering data from the table. This clause should not include the ORDER BY keyword. If it is not specified, the ORDER BY clause will not be generated in the query
Returns:
object containing the SQL query.
Throws:
DataServiceException

createInsertQuery

public static java.lang.String createInsertQuery(java.util.List pColumnsToInsert,
                                                 java.lang.String pFullyQualifiedTableName)
                                          throws DataServiceException
Returns a String containing a SQL INSERT statement for a given table with a list of columns to insert into.
Parameters:
pColumnsToInsert - list of column names to insert via the INSERT statement
pFullyQualifiedTableName - fully qualified name of the table on which the operation is carried out
Returns:
object containing the SQL query
Throws:
DataServiceException - thrown if the list of columns is empty.

createUpdateQuery

public static java.lang.String createUpdateQuery(java.util.List pColumnsToUpdate,
                                                 java.lang.String pFullyQualifiedTableName,
                                                 java.lang.String pWhereClause)
                                          throws DataServiceException
Returns a String containing a SQL UPDATE query for a given table with a list of columns to update and a given WHERE clause.
Parameters:
pColumnsToUpdate - list of column names to update.
pFullyQualifiedTableName - fully qualified name of the table on which the operation is carried out
pWhereClause - SQL WHERE Clause filtering data to update in the table. This clause should not include the WHERE keyword. If it is not specified, the clause will not be generated in the query
Returns:
object containing the SQL query
Throws:
DataServiceException - thrown if the list of columns is empty.

createDeleteQuery

public static java.lang.String createDeleteQuery(java.lang.String pFullyQualifiedTableName,
                                                 java.lang.String pWhereClause)
Returns a String containing a SQL DELETE statement with a WHERE clause for a given table.
Parameters:
pFullyQualifiedTableName - fully qualified name of the table on which the operation is carried out
pWhereClause - SQL WHERE Clause filtering data to delete in the table. This clause should not include the WHERE keyword. If it is not specified, the clause will not be generated in the query
Returns:
object containing the SQL query

createWhereClause

public static java.lang.String createWhereClause(QueryFilter pQueryFilter)
Returns a String containing a SQL WHERE clause generated from a QueryFilter. This clause includes both the QueryFilter's ManagedEntity used for filtering and the additional WHERE clause
Parameters:
pQueryFilter - QueryFilter object used to generate the filter
Returns:
object containing the SQL query

createWhereClause

public static java.lang.String createWhereClause(UpdateDeleteFilter pUpdateDeleteFilter)
Returns a String containing a SQL WHERE clause generated from a UpdateDeleteFilter. This clause includes both the UpdateDeleteFilter's ManagedEntity used for filtering and the additional WHERE clause
Parameters:
pUpdateDeleteFilter - UpdateDeleteFilter object used to generate the filter
Returns:
object containing the SQL query

Skip navigation links

Oracle© Data Integrator Data Services Java API Reference
11g Release 1 (11.1.1.5.0)

E17062-02


Copyright © 2011, Oracle and/or its affiliates. All rights reserved.