Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 38125 invoked from network); 9 Oct 2009 05:19:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Oct 2009 05:19:08 -0000 Received: (qmail 51415 invoked by uid 500); 9 Oct 2009 05:19:08 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 51393 invoked by uid 500); 9 Oct 2009 05:19:08 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 51385 invoked by uid 99); 9 Oct 2009 05:19:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Oct 2009 05:19:07 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Oct 2009 05:18:58 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Mw7sD-0004P7-AP for user-java@ibatis.apache.org; Thu, 08 Oct 2009 22:18:37 -0700 Message-ID: <25815639.post@talk.nabble.com> Date: Thu, 8 Oct 2009 22:18:37 -0700 (PDT) From: jishnu123 To: user-java@ibatis.apache.org Subject: Re: IBatis Array feild insertion problem in postgres database()Please help me) In-Reply-To: <4ACDD198.1050009@asci-systemhaus.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: rjishnu@gmail.com References: <25799490.post@talk.nabble.com> <4ACDD198.1050009@asci-systemhaus.de> X-Virus-Checked: Checked by ClamAV on apache.org Thank you for your reply...I have already implemented type handler and all classes as follows...But i got the the same error as follows....Please help me.....I didn't try array feild selection....I have been trying to insertio= n of array feild... I have to mention again that error as follows....Any body get an idea pleas= e reply immediately.. INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - INFO [org.springframework.jdbc.support.SQLErrorCodesFactory] - Ingmar L=C3=B6tzsch wrote: >=20 > You can use a type handler and implement java.sql.Array. Example: >=20 > 1st: abstract superclass as adapter >=20 > public abstract class SqlArrayAdapter > implements Array > { > =09public Object getArray() throws SQLException > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > =09 > =09public Object getArray(long index, int count) throws SQLException > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > =09 > =09public Object getArray(long index, int count, Map> > map) throws SQLException > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > =09 > =09public Object getArray(Map> map) throws SQLExceptio= n > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > =09 > =09public int getBaseType() throws SQLException > =09{ > =09=09// Auto-generated method stub > =09=09return 0; > =09} > =09 > =09public String getBaseTypeName() throws SQLException > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > =09 > =09public ResultSet getResultSet() throws SQLException > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > =09 > =09public ResultSet getResultSet(long index, int count) throws SQLExcepti= on > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > =09 > =09public ResultSet getResultSet(long index, int count, Map ? >> map) throws SQLException > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > =09 > =09public ResultSet getResultSet(Map> map) throws > SQLException > =09{ > =09=09// Auto-generated method stub > =09=09return null; > =09} > } >=20 > 2nd: implementation of java.sql.Array for use with int[] or > Collection >=20 > public class IntArray > extends SqlArrayAdapter > { > =09private static final Integer[] emptyArray =3D new Integer[0]; > =09 > =09private int[] array; > =09 > =09public IntArray(int[] array) > =09{ > =09=09if (array =3D=3D null) > =09=09{ > =09=09=09throw new IllegalArgumentException("parameter array should not b= e > null"); > =09=09} > =09=09this.array =3D array; > =09} > =09 > =09public IntArray(Collection set) > =09{ > =09=09if (set =3D=3D null) > =09=09{ > =09=09=09throw new IllegalArgumentException("parameter set should not be = null"); > =09=09} > =09=09Integer[] keys =3D set.toArray(emptyArray); >=20 > =09=09this.array =3D new int[keys.length]; > =09=09for (int i =3D 0; i < keys.length; ++i) > =09=09{ > =09=09=09Integer key =3D keys[i]; > =09=09=09this.array[i] =3D key.intValue(); > =09=09} > =09} > =09 > =09@Override > =09public int getBaseType() > //=09throws SQLException > =09{ > =09=09return Types.INTEGER; > =09} >=20 > =09/** > =09 * This method is called by driver ver. 8 but not by ver. 7. > =09 */ > =09@Override > =09public String getBaseTypeName() > //=09throws SQLException > =09{ > =09=09return "int4"; > =09} > =09 > =09/** > =09 * This method is called by both drivers ver. 8 and 7. > =09 */ > =09@Override > =09public String toString() > =09{ > =09=09String result =3D "{"; > =09=09for (int i =3D 0; i < this.array.length; ++i) > =09=09{ > =09=09=09if (i > 0) > =09=09=09{ > =09=09=09=09result +=3D ","; > =09=09=09} > =09=09=09result +=3D this.array[i]; > =09=09} > =09=09result +=3D "}"; > =09=09return result; > =09} > =09 > =09public void free() > //=09throws SQLException > =09{ > =09=09this.array =3D null; > =09} > } >=20 > 3rd: implementation of TypeHandlerCallback >=20 > public class IntArrayTypeHandler > implements TypeHandlerCallback > { > =09public void setParameter(ParameterSetter setter, Object parameter) > =09throws SQLException > =09{ > =09=09Collection keys =3D (Collection) parameter; > =09=09IntArray intArray =3D new IntArray(keys); > =09=09setter.setArray(intArray); > =09} > =09 > =09public Object getResult(ResultGetter getter) > =09throws SQLException > =09{ > =09=09Array array =3D getter.getArray(); > =09=09return array; > =09} > =09 > =09public Object valueOf(String string) > =09{ > =09=09return string; > =09} > } >=20 > 4th: add the type handler to your configuration > =09 type=3D"com.asci.common.ibatis.IntArrayTypeHandler" /> >=20 > 5th: SQL map >=20 > >=20 > 6th: DAO >=20 > public List selectFahrgastById(Set fahrgastIds) > { > =09HashMap params =3D new HashMap(); > =09params.put("fahrgastIds", fahrgastIds); > =09List list =3D getSqlMapClientTemplate().queryForList( > =09=09"datenerfassung.selectFahrgastById", params); > =09return list; > } >=20 > jishnu123 schrieb: >>=20 >> Hai, >>=20 >> I have to tried insertion of array feild in postgres database >> using >> spring mvc with iBatis.I got two lines error ...like=20 >>=20 >> Error as follows... >>=20 >>=20 >> [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - >> > XML bean definitions from class path resource >> [org/springframework/jdbc/support/sql-error-codes.xml]> >> [org.springframework.jdbc.support.SQLErrorCodesFactory] - > loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, >> PostgreSQL, >> Sybase]> >>=20 >>=20 >> Its urgent ....Please help me........Any one has an idea please=20 >> reply >> immediately otherwise sent to my emaild id rjishnu@gmail.com=20 >> =20 >>=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org > For additional commands, e-mail: user-java-help@ibatis.apache.org >=20 >=20 >=20 --=20 View this message in context: http://www.nabble.com/IBatis-Array-feild-inse= rtion-problem-in-postgres-database%28%29Please-help-me%29-tp25799490p258156= 39.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org For additional commands, e-mail: user-java-help@ibatis.apache.org