Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 369EE632C70 for ; Fri, 15 Jan 2010 10:50:10 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40664-02 for ; Fri, 15 Jan 2010 14:49:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from web94904.mail.in2.yahoo.com (web94904.mail.in2.yahoo.com [203.104.17.148]) by mail.postgresql.org (Postfix) with SMTP id 2D1F863225A for ; Fri, 15 Jan 2010 10:49:57 -0400 (AST) Received: (qmail 2029 invoked by uid 60001); 15 Jan 2010 14:49:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1263566993; bh=ej0rt6CWOvvvDrTMNWkx/UjooveptOM9xInr+b7haNM=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=V4TEGQurVvIndehRWr83dbQdBPMbceGltyBiIuCPKPv9AdsB1bjYhvGhOrEGIcSBEy6rZoK/aUNjO+JwOCeL+y/oAj3goHlkvmpotf4ezB5zTIAo3Tol7lTQqFSI+h8RFQTlBUvb7qS0tCtRCUaW1t104lhaNTNIfADyHfduJUc= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=lOW3FFaP0rhoUI0BZKmy9CG+VI8hSb3vdOJTSY3E7rD6tySDQNYrRVrUMsaAk3EY4Y/7/WZ2h/G0MnWjGS+MtQ6PCSOZtnt5jAofTnczQ2Z8hWJuMLbfKB8SnLv8ETt82b2BIiB2bVkDaXN7rmyZoilpDaALeGd+Z9gQyyqZHOI=; Message-ID: <399131.1865.qm@web94904.mail.in2.yahoo.com> X-YMail-OSG: BsOy58MVM1kVYC.02V9XeGA9cFuKLC_x4tNNp83nNTBj1LwII1b2kagRZkk8.qDyscGbzm.Mho8Vs7lY7SubSbxomuqkUWHMeInrB2k2FxU4i_CH729Ke1HwcVPlyL3rJAuZFCML4tmiTBWRyh3bIO76e1B1Ws12MR4XsJBQJOTnYALA3HRu3dtZzA3Otbc6NhO27P9rmF5uZVRcMJUW1ZHsm6f..FOhwKq7PWpHN13ErJ9R6ld7axhzW_na9FUmuyIcYqPoDvBOsco2.aztEmdK6z7QSSn6Nt0TqGd.033PkkVrhj0N.AYjfF1zakADR445vgaax7Q.ywDRDUAINzghEYc- Received: from [202.71.143.50] by web94904.mail.in2.yahoo.com via HTTP; Fri, 15 Jan 2010 20:19:53 IST X-Mailer: YahooMailRC/272.7 YahooMailWebService/0.8.100.260964 References: <170472.26453.qm@web94901.mail.in2.yahoo.com> <491f66a51001150400sf2c6b04l840af9f01c3e55bb@mail.gmail.com> <4B5066B1.6050709@postnewspapers.com.au> <82F2099D-4E4C-4073-A900-56A08DDEFD34@mchange.com> Date: Fri, 15 Jan 2010 20:19:53 +0530 (IST) From: Vaibhav Patil Subject: Re: COPY using Hibernate To: "pgsql-jdbc@postgresql.org" In-Reply-To: <82F2099D-4E4C-4073-A900-56A08DDEFD34@mchange.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1198699888-1263566993=:1865" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.002 tagged_above=-10 required=5 tests=BAYES_50=0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201001/25 X-Sequence-Number: 20221 --0-1198699888-1263566993=:1865 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thank you very much for you replies, I'll try these solutions as well and w= ill get back to you.=0A=0AThe other way I am trying is the pg/plsql stored = procedure. As per the requirement, I have to insert around a million intege= rs in a table having just one column. I am not aware of how to use "COPY FR= OM STDIN" using pg/plsql. I'll pass these integers as array to stored proce= dure. I want to avoid dependency of file, otherwise it could have been done= easily using "COPY FROM file". Looking for more information on internet to= solve the issue. If anybody aware of the way, please help me.=0A=0A=0AThan= ks,=0AVaibhav.=0A=0A=0A________________________________=0AFrom: Steve Waldm= an =0ATo: Craig Ringer = =0ACc: Dave Cramer ; Vaibhav Patil ; "pgsql-jdbc@postgresql.org" =0ASent: Fri, 15 = January, 2010 7:56:21 PM=0ASubject: Re: [JDBC] COPY using Hibernate=0A=0Ayo= u can just check out the inner Connection with c3p0's reflective API, if yo= u want. the preachiness is a speedbump, but nothing prevents you from retur= ning RAW_CONNECTION_OBJECT. just be sure that when you're done, the you've = not left the state of the Connection modified, cuz that can lead to subtle = misbehavior.=0A=0A~oo~=0ASteve Waldman=0Aswaldman@mchange.com=0A=0A=0AOn Ja= n 15, 2010, at 7:59 AM, Craig Ringer wrote:= =0A=0A> On 15/01/2010 8:00 PM, Dave Cramer wrote:=0A>> Hi Vaibhav=0A>> =0A>= > C3p0 provides a mechanism to get at the underlying connection and=0A>> st= atement. search for c3P0 underlying connection=0A> =0A> According to the C3= P0 docs:=0A> =0A> "JDBC drivers sometimes define vendor-specific, non-stand= ard API on Connection and Statement implementations. C3P0 wraps these Objec= ts behind a proxies, so you cannot cast C3P0-returned Connections or Statem= ents to the vendor-specific implementation classes. C3P0 does not provide a= ny means of accessing the raw Connections and Statements directly, because = C3P0 needs to keep track of Statements and ResultSets created in order to p= revent resource leaks and pool corruption."=0A> =0A> ... so, you can't just= get the connection from your Hibernate Session and use that. Instead, you = have to do it reflectively via C3P0 methods:=0A> =0A> "C3P0 does provide an= API that allows you to invoke non-standard methods=0A> reflectively on an = underlying Connection. To use it, first cast the=0A> returned Connection to= a C3P0ProxyConnection. Then call the method=0A> rawConnectionOperation, su= pplying the java.lang.reflect.Method object=0A> for the non-standard method= you wish to call as an argument. The Method=0A> you supply will be invoked= on the target you provide on the second=0A> argument (null for static meth= ods), and using the arguments you supply=0A> in the third argument to that = function. For the target, and for any of=0A> the method arguments, you can = supply the special token=0A> C3P0ProxyConnection.RAW_CONNECTION, which will= be replaced with the=0A> underlying vendor-specific Connection object befo= re the Method is invoked."=0A> =0A> See:=0A> http://www.mchange.com/projec= ts/c3p0/index.html#raw_connection_ops=0A> =0A> =0A> Permit me to say "argh!= ". It's highly frustrating that you can't just "check out" a connection, un= wrapping it and taking responsibility for any statements and result sets yo= u create while it's unwrapped.=0A> =0A> ( C3P0's documentation is really pr= eachy about this, and likes to=0A> explain to you how you shouldn't want t= o do "legacy" things like=0A> that since it breaks "database independence"= which is apparently=0A> something it's unthinkable not to care about for = your particular=0A> app ... sigh. )=0A> =0A> In my J2SE app I only need on= e connection for the app - and in fact it's strongly preferable to limit th= e app to one connection. I also needed direct access to that connection to = use listen/notify via PgConnection. Hibernate wants you to use a connection= pool, and jealously guards the connections it obtains via the pool - in fa= ct, if you're using Hibernate via JPA2 you can't access the underlying JDBC= connection *at* *all*.=0A> =0A> Thankfully Hibernate provides a clean and = simple abstraction for its access to connection pools, so I landed up writi= ng my own SingleConnectionProvider to give Hibernate its "pool" of one conn= ection. The provider blocks on any getConnection(...) requests issued while= the connection is checked out to someone else, so I can just check the con= nection out of the pool directly if I want to do PostgreSQL-specific things= with it ( like using listen/notify or COPY ) and use Hibernate the rest of= the time. It works great. If it'd be of any use to you, let me know.=0A> = =0A> --=0A> Craig Ringer=0A> =0A> --Sent via pgsql-jdbc mailing list (pgsql= -jdbc@postgresql.org)=0A> To make changes to your subscription:=0A> http://= www.postgresql.org/mailpref/pgsql-jdbc=0A=0A=0A=0A The INTERNET now ha= s a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/ --0-1198699888-1263566993=:1865 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Thank you very much for you replies, I'll try these solut= ions as well and will get back to you.

The other way I am trying is = the pg/plsql stored procedure. As per the requirement, I have to insert aro= und a million integers in a table having just one column. I am not aware of= how to use "COPY FROM STDIN" using pg/plsql. I'll pass these integers as a= rray to stored procedure. I want to avoid dependency of file, otherwise it = could have been done easily using "COPY FROM file". Looking for more inform= ation on internet to solve the issue. If anybody aware of the way, please h= elp me.

Thanks,
Vaibhav.

From: Steve Waldman <swaldman@mchange.com>
To: Craig Ringer <craig@postnewspapers.com.au= >
Cc: Dave Cramer &l= t;pg@fastcrypt.com>; Vaibhav Patil <infovaibhav@yahoo.com>; "pgsql= -jdbc@postgresql.org" <pgsql-jdbc@postgresql.org>
Sent: Fri, 15 January, 2010 7:56:21 PMSubject: Re: [JDBC] COPY= using Hibernate

you can just check out the inner Connection = with c3p0's reflective API, if you want. the preachiness is a speedbump, bu= t nothing prevents you from returning RAW_CONNECTION_OBJECT. just be sure t= hat when you're done, the you've not left the state of the Connection modif= ied, cuz that can lead to subtle misbehavior.

~oo~
Steve Waldman<= br>swaldman@mchange.com


On Jan 15, 2010, at 7:59 AM, Craig R= inger <craig@postnewspapers.com.au> wrote:
=
> On 15/01/2010 8:00 PM, Dave Cramer wrote:
>> Hi Vaibhav>>
>> C3p0 provides a mechanism to get at the underlying = connection and
>> statement. search for c3P0 underlying connection=
>
> According to the C3P0 docs:
>
> "JDBC driver= s sometimes define vendor-specific, non-standard API on Connection and Stat= ement implementations. C3P0 wraps these Objects behind a proxies, so you ca= nnot cast C3P0-returned Connections or Statements to the vendor-specific im= plementation classes. C3P0 does not provide any means of accessing the raw = Connections and Statements directly, because C3P0 needs to keep track of Statements and ResultSets created in order to prevent resource leaks and p= ool corruption."
>
> ... so, you can't just get the connection= from your Hibernate Session and use that. Instead, you have to do it refle= ctively via C3P0 methods:
>
> "C3P0 does provide an API that a= llows you to invoke non-standard methods
> reflectively on an underly= ing Connection. To use it, first cast the
> returned Connection to a = C3P0ProxyConnection. Then call the method
> rawConnectionOperation, s= upplying the java.lang.reflect.Method object
> for the non-standard m= ethod you wish to call as an argument. The Method
> you supply will b= e invoked on the target you provide on the second
> argument (null fo= r static methods), and using the arguments you supply
> in the third = argument to that function. For the target, and for any of
> the metho= d arguments, you can supply the special token
> C3P0ProxyConnection.RAW_CONNECTION, which will be replaced with the
>= ; underlying vendor-specific Connection object before the Method is invoked= ."
>
> See:
>  http://www.mch= ange.com/projects/c3p0/index.html#raw_connection_ops
>
> <= br>> Permit me to say "argh!". It's highly frustrating that you can't ju= st "check out" a connection, unwrapping it and taking responsibility for an= y statements and result sets you create while it's unwrapped.
>
&= gt; ( C3P0's documentation is really preachy about this, and likes to
&g= t;  explain to you how you shouldn't want to do "legacy" things like>  that since it breaks "database independence" which is apparent= ly
>  something it's unthinkable not to care about for your part= icular
>  app ... sigh. )
>
> In my J2SE app I only need one connection for the app - and in fact it's strongly preferabl= e to limit the app to one connection. I also needed direct access to that c= onnection to use listen/notify via PgConnection. Hibernate wants you to use= a connection pool, and jealously guards the connections it obtains via the= pool - in fact, if you're using Hibernate via JPA2 you can't access the un= derlying JDBC connection *at* *all*.
>
> Thankfully Hibernate = provides a clean and simple abstraction for its access to connection pools,= so I landed up writing my own SingleConnectionProvider to give Hibernate i= ts "pool" of one connection. The provider blocks on any getConnection(...) = requests issued while the connection is checked out to someone else, so I c= an just check the connection out of the pool directly if I want to do Postg= reSQL-specific things with it ( like using listen/notify or COPY ) and use = Hibernate the rest of the time. It works great. If it'd be of any use to you, let me know.
>
> --
> Craig Ringer
> =
> --Sent via pgsql-jdbc mailing list (pgsql-jdbc@post= gresql.org)
> To make changes to your subscription:
> http= ://www.postgresql.org/mailpref/pgsql-jdbc
=0A=0A
=0A=0A=0A=0A
=0AThe INTERNET now has a per= sonality. YOURS! See your Yahoo! Homepage. --0-1198699888-1263566993=:1865--