ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yu, Jack" <Jack...@fmr.com>
Subject How to pass Array as parameter?
Date Wed, 03 Oct 2007 21:10:42 GMT
I would need to pass Array in the call, but I couldn't find out feasible
way to wrap around my objects to java.sql.Array.

In Oracle, it appears I could use "ARRAY" to create, but ARRAY object
need ArrayDescriptor which requires access to Connection object, which I
am not sure how to get in the ibatis environment.

I am trying to play around the setParameter in TypeHandlerCallback
interface, here is what I come out. It works in Oracle environment, but
I would like to get some feedback before I check in the code.


	public void setParameter(ParameterSetter setter, Object
parameter) throws SQLException {
		if (parameter instanceof DBArray) {
			DBArray arr = (DBArray)parameter;
			// convert SQLData[] to Array
			Statement stmt = setter.getPreparedStatement();
			Connection conn = stmt.getConnection();
			ArrayDescriptor  desc = new ArrayDescriptor
(arr.getSqlType(), conn);
			parameter = new ARRAY(desc, conn,

View raw message