rachel06
Aug 4th, 2010, 10:20 AM
i have a stored procedure in postgres which takes array as parameter
eg: CREATE OR REPLACE FUNCTION testprocedure(data integer[])
RETURNS void AS......
when executing this procedure from postgres using the command
SELECT testprocedure ( ARRAY [1,2,3,4])
it works fine . But executing the same stored procedure via java gives
exception.
i have a java class which extends from org.springframework.jdbc.object.StoredProcedure
and have overridden the execute method
Map map = new HashMap();
int[] testdata = new int[] {1,2,3,4,5,6,7};
map.put("data", testdata );
declareParameter(new SqlParameter("data", Types.ARRAY));
but on executing the stored procedure i'm getting
org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{call testprocedure (?)}]; nested exception is org.postgresql.util.PSQLException: Cannot cast an instance of [I to type Types.ARRAY
at org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator.doTranslate(SQLStateSQLExceptionTran slator.java:98)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:969)
at org.springframework.jdbc.core.JdbcTemplate.call(Jd bcTemplate.java:1003)
at org.springframework.jdbc.object.StoredProcedure.ex ecute(StoredProcedure.java:144)
Please help ...
eg: CREATE OR REPLACE FUNCTION testprocedure(data integer[])
RETURNS void AS......
when executing this procedure from postgres using the command
SELECT testprocedure ( ARRAY [1,2,3,4])
it works fine . But executing the same stored procedure via java gives
exception.
i have a java class which extends from org.springframework.jdbc.object.StoredProcedure
and have overridden the execute method
Map map = new HashMap();
int[] testdata = new int[] {1,2,3,4,5,6,7};
map.put("data", testdata );
declareParameter(new SqlParameter("data", Types.ARRAY));
but on executing the stored procedure i'm getting
org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{call testprocedure (?)}]; nested exception is org.postgresql.util.PSQLException: Cannot cast an instance of [I to type Types.ARRAY
at org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator.doTranslate(SQLStateSQLExceptionTran slator.java:98)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackS QLExceptionTranslator.translate(AbstractFallbackSQ LExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:969)
at org.springframework.jdbc.core.JdbcTemplate.call(Jd bcTemplate.java:1003)
at org.springframework.jdbc.object.StoredProcedure.ex ecute(StoredProcedure.java:144)
Please help ...