Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WTUVQ-00048G-6t for pgsql-jdbc@arkaria.postgresql.org; Fri, 28 Mar 2014 10:59:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WTUVP-0001mK-HX for pgsql-jdbc@arkaria.postgresql.org; Fri, 28 Mar 2014 10:59:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WTUVO-0001mD-DM for pgsql-jdbc@postgresql.org; Fri, 28 Mar 2014 10:59:22 +0000 Received: from st11p05mm-asmtp001.mac.com ([17.172.108.249]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WTUVF-0004l4-0p for pgsql-jdbc@postgresql.org; Fri, 28 Mar 2014 10:59:21 +0000 MIME-version: 1.0 Content-type: multipart/alternative; boundary="Boundary_(ID_OWoxGNohjB89k1BI5SdfJQ)" Received: from [192.168.1.132] (209.249.209.130.available.above.net [209.249.209.130]) by st11p05mm-asmtp001.mac.com (Oracle Communications Messaging Server 7u4-27.08(7.0.4.27.7) 64bit (built Aug 22 2013)) with ESMTPSA id <0N350028H7UIWR50@st11p05mm-asmtp001.mac.com> for pgsql-jdbc@postgresql.org; Fri, 28 Mar 2014 10:59:09 +0000 (GMT) Subject: Re: Re: Inputs Appreciated - Calling pgsql stored proc with user defined sql types from java using pgsql-jdbc From: Kevin Wooten In-reply-to: Date: Fri, 28 Mar 2014 05:59:06 -0500 Cc: David Johnston , pgsql-jdbc@postgresql.org Message-id: <6255001B-B300-41DD-BA31-90F2F68200F4@me.com> References: <1395984172711-5797744.post@n5.nabble.com> <1395991099706-5797751.post@n5.nabble.com> To: Venkateswar Reddy Melachervu X-Mailer: Apple Mail (2.1874) X-MANTSH: 1TEIXWV4bG1oaGkdHB0lGUkdDRl5PWBoaEhEKTEMXGx0EGx0YBBIZBBsTEBseGh8 aEQpYTRdLEQptfhcaEQpMWRcbGhsbEQpZSRcRClleF2hjeREKQ04XSxseGmJCH2lmG2RYGXhzB xh5GxofExIZEQpYXBcZBBoEHQdNSx0SSEkcTAUbHQQbHRgEEhkEGxMQGx4aHxsRCl5ZF2FLXFt yEQpMRhdia2sRCkNaFxgaEwQYHhMEGBoTBBsZGhEKRFgXGREKREkXGBEKQkYXbUBDSUdPaWMYR 1IRCkJFF2J/W3kYRlhmQEVLEQpCThdscGB5QB1iUmkaYhEKQkwXbV5bW0Vcfx18U2URCkJsF2Z wYBlAfWEZXxwZEQpCQBduQGNTfk0cZklzYBEKcGcXYhIdf0lecgVjbEYRCnBoF2xCTklNXWFme RgbEQpwaBdgQQUaGmYcaWZHbxEKcGgXbhxvE0d7TXN7WWQRCnBoF2NaTRpab0tmb3oBEQpwaBd nXEBuS21BbGIZfxEKcH8Xax1rHlN7Z2NLbXoRCnBfF3oYY1xuaENbTkVjEQpwfxdvRGFQEhN/G xwSfhEKcF8XaBNnaFlAQ1sbUGwRCnB/F20bH0lya0N/QRppEQpwXxdmRG9MSxpNRhkTXhEKcH8 XemhrGGF7Q14Bbk4RCnBfF2R9TWlne05ieG8BEQpwfxdgWm1jGnJgHm9OYxEKcF8XYxtbQ2xgH FxBElsRCnBnF295aBNkYHlhZV5AEQpwbBdse15gXBxeTBpFYxEKcEwXYEQcT1AFAXIFbXMR X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.87,1.0.14,0.0.0000 definitions=2014-03-28_04:2014-03-28,2014-03-28,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1403280036 X-Pg-Spam-Score: -3.1 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org --Boundary_(ID_OWoxGNohjB89k1BI5SdfJQ) Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT You might try this driver: https://github.com/impossibl/pgjdbc-ng It supports UDTs and even registerOutParameter according to the JDBC 4.1 spec. On Mar 28, 2014, at 4:24 AM, Venkateswar Reddy Melachervu wrote: > Dave, > When I tried with type map approach as suggested by you, it throws a run time exception : "(org.postgresql.util.PSQLException) org.postgresql.util.PSQLException: Custom type maps are not supported". Snipper below > Connection physicalDBConn = ((javax.sql.PooledConnection)dbConn).getConnection(); > Map> udtMap = new HashMap<>(); > udtMap.put("type_customer_details_for_subscription", > com.brillium.vcossPortalServer.datalayer.pgsql.udt.CreatedCustomerMVCAccountDetails.class); > udtMap.put("type_mvc_plans_details", > com.brillium.vcossPortalServer.datalayer.pgsql.udt.MVCPlanDetails.class); > udtMap.put("type_mvc_countries_map", > com.brillium.vcossPortalServer.datalayer.pgsql.udt.CountryCodesMap.class); > //myMap.put("mySchemaName.ATHLETES", Athletes.class); > physicalDBConn.setTypeMap(udtMap); > > V > > > On Fri, Mar 28, 2014 at 2:26 PM, Venkateswar Reddy Melachervu wrote: > Thanks again. Here is the snipper causing the cast error with jdbc41 pgsql driver > > //code snippet -begin > dbConn = VCOSSDBUtils.getVCOSSDBConnection(); > dbConn.setAutoCommit(true); > Connection physicalDBConn = ((javax.sql.PooledConnection)dbConn).getConnection(); //get the real conn from the pooled conn > ((org.postgresql.PGConnection)physicalDBConn).addDataType("type_customer_details_for_subscription", > com.brillium.vcossPortalServer.datalayer.pgsql.udt.CreatedCustomerMVCAccountDetails.class); > ((org.postgresql.PGConnection)physicalDBConn).addDataType("type_mvc_plans_details", > com.brillium.vcossPortalServer.datalayer.pgsql.udt.MVCPlanDetails.class); > ((org.postgresql.PGConnection)physicalDBConn).addDataType("type_mvc_countries_map", > com.brillium.vcossPortalServer.datalayer.pgsql.udt.CountryCodesMap.class); > //code snippet - end > > When I run, the exception occurs at first cat statement above! > > V > > > On Fri, Mar 28, 2014 at 12:48 PM, David Johnston wrote: > The cast should work but while you wait for someone to confirm/comment you > might just try using the setTypeMap(...) method of the Jdbc4Connection > > Supplying minimal code showing the problem might help too... > > David J. > > > Venkateswar Reddy Melachervu wrote > > ok. Thanks for the quick response Dave. > > > > This post provides a for achieving what my solution requires - passing > > user > > defined data types to stored > > procedures. > > I followed this post ( of course, adapted it to suit for jdbc41 pgsql > > driver). Per this to add the data type, the jdbc connection needs to be > > cast to pgconnection and this casting is resulting in a run time exception > > - (java.lang.ClassCastException) java.lang.ClassCastException: > > org.postgresql.jdbc4.Jdbc4Connection cannot be cast to > > org.postgresql.PGConnection. > > > > This was not the case with pgsql8.3 with jdbc3/4 pgsql driver. > > > > Any pointer/inputs to resolve this are highly appreciated. > > > > V > > > > > > On Fri, Mar 28, 2014 at 10:52 AM, David Johnston < > > > polobo@ > > > > wrote: > > > >> Venkateswar Reddy Melachervu wrote > >> > Hello All, > >> > Any inputs/pointers for the below are highly appreciated. > >> > > >> > Problem > >> > When trying to conn.registerOutParameter(2, > >> > Types.STRUCT,"type_customer_details_for_subscription") for a pgsql > >> stored > >> > proc with user defined type from java1.7 using jdbc41 pgsql driver to > >> > pgsql9.3 is resulting in error when type maps are used - > >> > SQLFeatureNotSupportedException: Method > >> > > >> org.postgresql.jdbc4.Jdbc4CallableStatement.registerOutParameter(int,int,String) > >> > is not yet implemented. > >> > > >> > Somehow I was under the impression that struct for sql is base type and > >> > pgsql jdbc driver can support it. But going by above exception message, > >> it > >> > it not. am I doing something wrong (have to create some struct pointers > >> > etc. before registering the type) or it is the way pgsql jdbc driver is > >> > built. Is there any way out - any pointer? > >> > > >> > -- > >> > Regards, > >> > Venkateswar Reddy Melachervu > >> > "...dare to dream, care to win..." > >> > www.linkedin.com/in/vmelachervu > >> > >> registerOutParameter(...) is not implemented - it doesn't matter what the > >> actual argument values are. > >> > >> Sorry, no help on the solution. > >> > >> David J. > >> > >> > >> > >> > >> > >> -- > >> View this message in context: > >> http://postgresql.1045698.n5.nabble.com/Inputs-Appreciated-Calling-pgsql-stored-proc-with-user-defined-sql-types-from-java-using-pgsql-jdbc-tp5797743p5797744.html > >> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com. > >> > >> > >> -- > >> Sent via pgsql-jdbc mailing list ( > > > pgsql-jdbc@ > > > ) > >> To make changes to your subscription: > >> http://www.postgresql.org/mailpref/pgsql-jdbc > >> > > > > > > > > -- > > Regards, > > Venkateswar Reddy Melachervu > > "...dare to dream, care to win..." > > www.linkedin.com/in/vmelachervu > > > > > > -- > View this message in context: http://postgresql.1045698.n5.nabble.com/Inputs-Appreciated-Calling-pgsql-stored-proc-with-user-defined-sql-types-from-java-using-pgsql-jdbc-tp5797743p5797751.html > Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com. > > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc > > > > -- > Regards, > Venkateswar Reddy Melachervu > "...dare to dream, care to win..." > www.linkedin.com/in/vmelachervu > > > > -- > Regards, > Venkateswar Reddy Melachervu > "...dare to dream, care to win..." > www.linkedin.com/in/vmelachervu --Boundary_(ID_OWoxGNohjB89k1BI5SdfJQ) Content-type: text/html; CHARSET=US-ASCII Content-transfer-encoding: 7BIT You might try this driver: https://github.com/impossibl/pgjdbc-ng

It supports UDTs and even registerOutParameter according to the JDBC 4.1 spec. 

On Mar 28, 2014, at 4:24 AM, Venkateswar Reddy Melachervu <vmelachervu@gmail.com> wrote:

Dave,
When I tried with type map approach as suggested by you, it throws a run time exception : "(org.postgresql.util.PSQLException) org.postgresql.util.PSQLException: Custom type maps are not supported". Snipper below
                Connection physicalDBConn = ((javax.sql.PooledConnection)dbConn).getConnection(); 
                Map<String,Class<?>> udtMap = new HashMap<>();                                
                udtMap.put("type_customer_details_for_subscription",
                        com.brillium.vcossPortalServer.datalayer.pgsql.udt.CreatedCustomerMVCAccountDetails.class);                                               
                udtMap.put("type_mvc_plans_details",
                        com.brillium.vcossPortalServer.datalayer.pgsql.udt.MVCPlanDetails.class);
                udtMap.put("type_mvc_countries_map",
                        com.brillium.vcossPortalServer.datalayer.pgsql.udt.CountryCodesMap.class);
                //myMap.put("mySchemaName.ATHLETES", Athletes.class);
                physicalDBConn.setTypeMap(udtMap);

V


On Fri, Mar 28, 2014 at 2:26 PM, Venkateswar Reddy Melachervu <vmelachervu@gmail.com> wrote:
Thanks again. Here is the snipper causing the cast error with jdbc41 pgsql driver

//code snippet -begin
dbConn = VCOSSDBUtils.getVCOSSDBConnection();                
dbConn.setAutoCommit(true);
Connection physicalDBConn = ((javax.sql.PooledConnection)dbConn).getConnection(); //get the real conn from the pooled conn
((org.postgresql.PGConnection)physicalDBConn).addDataType("type_customer_details_for_subscription", 
                        com.brillium.vcossPortalServer.datalayer.pgsql.udt.CreatedCustomerMVCAccountDetails.class);       
                ((org.postgresql.PGConnection)physicalDBConn).addDataType("type_mvc_plans_details", 
                        com.brillium.vcossPortalServer.datalayer.pgsql.udt.MVCPlanDetails.class);                  
                ((org.postgresql.PGConnection)physicalDBConn).addDataType("type_mvc_countries_map", 
                    com.brillium.vcossPortalServer.datalayer.pgsql.udt.CountryCodesMap.class); 
//code snippet - end

When I run, the exception occurs at first cat statement above!

V


On Fri, Mar 28, 2014 at 12:48 PM, David Johnston <polobo@yahoo.com> wrote:
The cast should work but while you wait for someone to confirm/comment you
might just try using the setTypeMap(...) method of the Jdbc4Connection

Supplying minimal code showing the problem might help too...

David J.


Venkateswar Reddy Melachervu wrote
> ok. Thanks for the quick response Dave.
>
> This post provides a for achieving what my solution requires - passing
> user
> defined data types to stored
> procedures<https://groups.google.com/forum/#!topic/pgsql.interfaces.jdbc/Tj-LUrhFowQ>.
> I followed this post ( of course, adapted it to suit for jdbc41 pgsql
> driver). Per this to add the data type, the jdbc connection needs to be
> cast to pgconnection and this casting is resulting in a run time exception
> -  (java.lang.ClassCastException) java.lang.ClassCastException:
> org.postgresql.jdbc4.Jdbc4Connection cannot be cast to
> org.postgresql.PGConnection.
>
> This was not the case with pgsql8.3 with jdbc3/4 pgsql driver.
>
> Any pointer/inputs to resolve this are highly appreciated.
>
> V
>
>
> On Fri, Mar 28, 2014 at 10:52 AM, David Johnston <

> polobo@

> > wrote:
>
>> Venkateswar Reddy Melachervu wrote
>> > Hello All,
>> > Any inputs/pointers for the below are highly appreciated.
>> >
>> > Problem
>> > When trying to conn.registerOutParameter(2,
>> > Types.STRUCT,"type_customer_details_for_subscription") for a pgsql
>> stored
>> > proc with user defined type from java1.7 using jdbc41 pgsql driver to
>> > pgsql9.3 is resulting in error when type maps are used -
>> > SQLFeatureNotSupportedException: Method
>> >
>> org.postgresql.jdbc4.Jdbc4CallableStatement.registerOutParameter(int,int,String)
>> > is not yet implemented.
>> >
>> > Somehow I was under the impression that struct for sql is base type and
>> > pgsql jdbc driver can support it. But going by above exception message,
>> it
>> > it not. am I doing something wrong (have to create some struct pointers
>> > etc. before registering the type) or it is the way pgsql jdbc driver is
>> > built. Is there any way out  - any pointer?
>> >
>> > --
>> > Regards,
>> > Venkateswar Reddy Melachervu
>> > "...dare to dream, care to win..."
>> > www.linkedin.com/in/vmelachervu
>>
>> registerOutParameter(...) is not implemented - it doesn't matter what the
>> actual argument values are.
>>
>>  Sorry, no help on the solution.
>>
>> David J.
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://postgresql.1045698.n5.nabble.com/Inputs-Appreciated-Calling-pgsql-stored-proc-with-user-defined-sql-types-from-java-using-pgsql-jdbc-tp5797743p5797744.html
>> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>>
>>
>> --
>> Sent via pgsql-jdbc mailing list (

> pgsql-jdbc@

> )
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-jdbc
>>
>
>
>
> --
> Regards,
> Venkateswar Reddy Melachervu
> "...dare to dream, care to win..."
> www.linkedin.com/in/vmelachervu





--
View this message in context: http://postgresql.1045698.n5.nabble.com/Inputs-Appreciated-Calling-pgsql-stored-proc-with-user-defined-sql-types-from-java-using-pgsql-jdbc-tp5797743p5797751.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



--
Regards,
Venkateswar Reddy Melachervu
"...dare to dream, care to win..."



--
Regards,
Venkateswar Reddy Melachervu
"...dare to dream, care to win..."

--Boundary_(ID_OWoxGNohjB89k1BI5SdfJQ)--