public class SQLDatasourceUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
POSTGRES_DATABASE_NAME |
static String |
POSTGRES_OID_COLUMN_TYPE_NAME |
| Constructor and Description |
|---|
SQLDatasourceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
cleanupResources(List<ResultSet> resultSets,
Statement stmt,
Connection conn,
boolean connectionClosable)
This will close database connection, statement and result sets.
|
static void |
cleanupResources(ResultSet rs,
Statement stmt,
Connection conn,
boolean connectionClosable)
This will close database connection, statement and the resultset.
|
static void |
cleanupResources(Statement stmt,
Connection conn,
boolean connectionClosable)
This will close database connection and statement.
|
static String |
createJDBCDbOptions(String propertiesBeginSymbol,
String separator,
Map<String,Value> dbOptions) |
static BMap<String,BValue> |
createMultiModeDBClient(Context context,
String dbType,
Struct clientEndpointConfig,
String urlOptions) |
static BMap<String,BValue> |
createServerBasedDBClient(Context context,
String dbType,
Struct clientEndpointConfig,
String urlOptions) |
static BMap<String,BValue> |
createSQLDBClient(Context context,
Struct clientEndpointConfig) |
static List<ColumnDefinition> |
getColumnDefinitions(ResultSet rs) |
static Connection |
getDatabaseConnection(Context context,
SQLDatasource datasource,
boolean isSelectQuery) |
static BError |
getSQLConnectorError(Context context,
Throwable throwable) |
static String |
getSQLType(BType value) |
static String |
getString(Array dataArray)
This will retrieve the string value for the given array data.
|
static String |
getString(Blob data)
This will retrieve the string value for the given blob.
|
static String |
getString(byte[] data)
This will retrieve the string value for the given binary data.
|
static String |
getString(Clob data)
This will retrieve the string value for the given clob.
|
static String |
getString(Date value) |
static String |
getString(Struct udt)
This will retrieve the string value for the given struct data.
|
static void |
handleErrorOnTransaction(Context context) |
static void |
setArrayValue(Connection conn,
PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType,
String databaseProductName) |
static void |
setBigIntValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setBinaryValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setBlobValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setBooleanValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setClobValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setDateValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setDoubleValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setIntValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setNClobValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setNStringValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setNullObject(PreparedStatement stmt,
int index) |
static void |
setNumericValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setRealValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setRefCursorValue(PreparedStatement stmt,
int index,
int direction,
String databaseProductName) |
static void |
setSmallIntValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setStringValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setTimeStampValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType,
Calendar utcCalendar) |
static void |
setTimeValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType,
Calendar utcCalendar) |
static void |
setTinyIntValue(PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
static void |
setUserDefinedValue(Connection conn,
PreparedStatement stmt,
BValue value,
int index,
int direction,
int sqlType) |
public static final String POSTGRES_DATABASE_NAME
public static final String POSTGRES_OID_COLUMN_TYPE_NAME
public static void setIntValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setSmallIntValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setStringValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setNStringValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setDoubleValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setNumericValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setBooleanValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setTinyIntValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setBigIntValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setRealValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setDateValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setTimeStampValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType, Calendar utcCalendar)
public static void setTimeValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType, Calendar utcCalendar)
public static void setBinaryValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setBlobValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setClobValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setNClobValue(PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void setRefCursorValue(PreparedStatement stmt, int index, int direction, String databaseProductName)
public static void setArrayValue(Connection conn, PreparedStatement stmt, BValue value, int index, int direction, int sqlType, String databaseProductName)
public static void setNullObject(PreparedStatement stmt, int index)
public static void setUserDefinedValue(Connection conn, PreparedStatement stmt, BValue value, int index, int direction, int sqlType)
public static void cleanupResources(List<ResultSet> resultSets, Statement stmt, Connection conn, boolean connectionClosable)
resultSets - SQL result setsstmt - SQL statementconn - SQL connectionconnectionClosable - Whether the connection is closable or not. If the connection is not closable this
method will not release the connection. Therefore to avoid connection leaks it should have been taken care
of externally.public static void cleanupResources(ResultSet rs, Statement stmt, Connection conn, boolean connectionClosable)
rs - SQL resultsetstmt - SQL statementconn - SQL connectionconnectionClosable - Whether the connection is closable or not. If the connection is not closable this
method will not release the connection. Therefore to avoid connection leaks it should have been taken care
of externally.public static void cleanupResources(Statement stmt, Connection conn, boolean connectionClosable)
stmt - SQL statementconn - SQL connectionconnectionClosable - Whether the connection is closable or not. If the connection is not closable this
method will not release the connection. Therefore to avoid connection leaks it should have been taken care
of externally.public static String getString(Clob data)
data - clob datapublic static String getString(Blob data)
data - blob datapublic static String getString(byte[] data)
data - binary datapublic static String getString(Array dataArray) throws SQLException
dataArray - dataSQLException - sql exception when reading result setpublic static String getString(Struct udt) throws SQLException
udt - structSQLException - sql exception when reading result setpublic static BError getSQLConnectorError(Context context, Throwable throwable)
public static void handleErrorOnTransaction(Context context)
public static BMap<String,BValue> createServerBasedDBClient(Context context, String dbType, Struct clientEndpointConfig, String urlOptions)
public static BMap<String,BValue> createSQLDBClient(Context context, Struct clientEndpointConfig)
public static BMap<String,BValue> createMultiModeDBClient(Context context, String dbType, Struct clientEndpointConfig, String urlOptions)
public static List<ColumnDefinition> getColumnDefinitions(ResultSet rs) throws SQLException
SQLExceptionpublic static Connection getDatabaseConnection(Context context, SQLDatasource datasource, boolean isSelectQuery) throws SQLException
SQLExceptionCopyright © 2019 WSO2. All rights reserved.