JDBC user defined data types
-
Upload
cong-thanh-nguyen -
Category
Technology
-
view
61 -
download
0
Transcript of JDBC user defined data types
JDBC User-Defined Data Types
Thanh Nguyen
Instructions
• In Mule 3.6 and newer, you can use user-defined data types with the Database connector
• This feature provides the ability to use JDBC supported types in a query; for example, array, struct, and other types
Instructions
• To use a JDBC data type, specify the type in the database configuration by the name of the type, along with type ID corresponding to the structured data type
Struct Type
• If you created a type in your database using the syntax CREATE TYPE xyz AS OBJECT you have created a struct
• The database connector understands this as java.sql.Struct
• In order to obtain the information about the struct, use MEL to invoke the getAttributes method of this Java type
Array Type
• For array values, the connector returns java.sql.Array• In order to obtain the corresponding Java array,
invoke the getArray method on the java.sql.Array instance
• This requires an open connection to the database, which means that the query returning the array must be executed inside a transactional scope or using streaming, checking the box in the connector properties pane
Passing User-Defined Data Types to Stored Procedure
• To pass a user-defined data type to a stored procedure, the data type should be specified in the database configuration with a number id identifying the JDBC type it conforms to
• The parameter you pass to the stored procedure should be referenced by the name of the data type
Passing User-Defined Data Types to Stored Procedure
Example MEL Expression for Database URL
Question and answer