Article View: borland.public.jbuilder.java.language
Article #8519Re: another new Connection for two Resul?
From: Avi Abrami
Date: Sun, 18 Mar 2001 05:55
Date: Sun, 18 Mar 2001 05:55
54 lines
2521 bytes
2521 bytes
Stephen (and Torsten),
I just wanted to add that I discovered that with Oracle's
JDBC driver and an Oracle 8.1.6 database, the "Connection"
interface is not multi-threaded. In other words, if you perform
a "Statement.executeQuery" from two separate threads
simultaneously against the same "Connection" the second
thread will block until the "Connection" returns the first
thread's "ResultSet".
HTH,
Avi.
Torsten Welches wrote:
> Stephen,
>
> you don't need two Connections, but two Statements. One Statement
> can only serve one ResultSet.
> You might also want to verify if what your are after isn't doable
> with *one* SQL statement - join, subselect and so on.
>
> Torsten
>
> "Stephen Zeng" <chinafax1@cmmail.com> wrote:
> > Connection con=DriverManager.getConnection("jdbc:odbc:expresso","sa","");
> > Statement sqlstr=con.createStatement();
> > Statement trasql=con.createStatement();
> >
> > ResultSet firstrs=sqlstr.executeQuery("....");
> >
> > while (firstrs.next()) {
> >
> > System.out.println(firstrs.getString(1));
> >
> >
> > // next result set
> > ResultSet secondrs=sqlstr.executeQuery("...");
> >
> > while (secondrs.next()) {
> > System.out.println(secondrs.getString(1));
> >
> >// error: Connection is busy with results for another Statment,
> >// Does it means I need create New Connection for each ResultSet? if that
> >is the case,
> >// it will occupy large Server resource?
> >// Or is there any better method?
> >
> > }
> >
> > }
> >
> >
> >
> >
Technical Details
Message-ID:
<3AB44DBF.FF2D1197@intersystemsww.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!212.25.80.54References:
<3ab17350_1@dnews> <3ab1b7e4$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,706e71a4e5ab8522 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-17 22:14:04 PST Message-ID: <3AB44DBF.FF2D1197@intersystemsww.com> Date: Sun, 18 Mar 2001 07:55:11 +0200 From: Avi Abrami <aabrami@intersystemsww.com> Organization: InterSystems Ltd X-Mailer: Mozilla 4.73 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Re: another new Connection for two Resul? References: <3ab17350_1@dnews> <3ab1b7e4$1_2@dnews> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 212.25.80.54 X-Trace: 17 Mar 2001 21:58:05 -0800, 212.25.80.54 Lines: 55 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!212.25.80.54