🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.database
Article #212

Re: ProcedureDataSet and resultSetToDataSet doesn't work

#212
From: John Moore (TeamB)
Date: Wed, 28 Jun 2006 21:19
211 lines
8678 bytes
Christa,

The error appears to be in

org.postgresql.jdbc1.AbstractJdbc1ResultSet.next


Normally I would have used..

while (pr.inbounds()) {
        System.out.println(pr.getString(3));
        pr.next();
}

... to walk the dataset..

Also your syntax for the procedure call may be off..  It looks like you 
are using the function call not the procedure call syntax..

{ call ProcedureName (?,?,?)}

What I would suggest is to great a small "application" and use the 
ProcedureDataSet property dialog to make these settings.. Then you can 
use "Browse Procedures" and it will help write the code for the setup.

Sorry I'm not that much help.. I mostly use Interbase/Firebird and I 
access store procedures using the select syntax

John...

Christa Schneider wrote:
> Thank you very much, I will try it.
> 
> I think it is not the best way, but I know no other.
> 
> I have a problem with setProcedure too!
> I haven't found any example that works.
> 
> Is there a way to run this?
> 
> Database db = new Database();
> ProcedureDataSet pr = new ProcedureDataSet();
>  db.setAutoCommit(false);
>     row.addColumn("ref", Variant.OBJECT, ParameterType.OUT);
>     row.getColumn("ref").setSqlType(Types.OTHER);
>     row.addColumn("krit", Variant.STRING, ParameterType.IN);
>     row.setString("krit", "where k_kd_id=15");
> 
>     //  pr.addColumn("ref",Variant.OBJECT);
>     //  pr.addColumn("krit",Variant.STRING);
> 
>     pr.setProcedure(new com.borland.dx.sql.dataset.ProcedureDescriptor(db, 
> "{:ref = call func_tn_im_kurs(:krit) }", row, true, 
> Load.ALL));
> 
>     //pr.open(); // Exeption: close the DataSet first.
> 
>     pr.executeQuery();  //GET THE Exception
> 
>     while (pr.next()) {
>           System.out.println(pr.getString(3));
>    }
> 
> See com.borland.dx.dataset.DataSetException error code:  BASE+47
> com.borland.dx.dataset.DataSetException: Chain of 2 or more Exceptions 
> occurred
>  at com.borland.dx.dataset.DataSetException.a(Unknown Source)
>  at com.borland.dx.dataset.DataSetException.throwExceptionChain(Unknown 
> Source)
>  at com.borland.dx.sql.dataset.JdbcProvider.c(Unknown Source)
>  at com.borland.dx.sql.dataset.JdbcProvider.provideData(Unknown Source)
>  at com.borland.dx.dataset.StorageDataSet.refresh(Unknown Source)
>  at com.borland.dx.sql.dataset.ProcedureDataSet.refresh(Unknown Source)
>  at com.borland.dx.sql.dataset.ProcedureDataSet.executeQuery(Unknown Source)
>  at tools.StoredTest.jbInit(StoredTest.java:68)
>  at tools.StoredTest.<init>(StoredTest.java:20)
>  at tools.StoredTest.main(StoredTest.java:29)
> Chained exception:
> org.postgresql.util.PSQLException: Connection is closed.  Operation is not 
> permitted.
>  at 
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.next(AbstractJdbc1ResultSet.java:138)
>  at com.borland.dx.sql.dataset.JdbcProvider.a(Unknown Source)
>  at com.borland.dx.sql.dataset.JdbcProvider.c(Unknown Source)
>  at com.borland.dx.sql.dataset.JdbcProvider.provideData(Unknown Source)
>  at com.borland.dx.dataset.StorageDataSet.refresh(Unknown Source)
>  at com.borland.dx.sql.dataset.ProcedureDataSet.refresh(Unknown Source)
>  at com.borland.dx.sql.dataset.ProcedureDataSet.executeQuery(Unknown Source)
>  at tools.StoredTest.jbInit(StoredTest.java:68)
>  at tools.StoredTest.<init>(StoredTest.java:20)
>  at tools.StoredTest.main(StoredTest.java:29)
> 
> Thanks
> Christa
> 
> 
> "John Moore (TeamB)" <jbm@microps.com> schrieb im Newsbeitrag 
> news:44a023aa$1@newsgroups.borland.com...
>> Christa Schneider wrote:
>>> Here the exeption:
>>> java.lang.NullPointerException
>>>  at 
>>> org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.getColumnCount(AbstractJdbc2ResultSetMetaData.java:34)
>>>  at com.borland.dx.sql.dataset.RuntimeMetaData.a(Unknown Source)
>>>  at com.borland.dx.sql.dataset.JdbcProvider.a(Unknown Source)
>>>  at com.borland.dx.sql.dataset.Database.resultSetToDataSet(Unknown 
>>> Source)
>>>  at tools.StoredTest.jbInit(StoredTest.java:73)
>>>  at tools.StoredTest.<init>(StoredTest.java:20)
>>>  at tools.StoredTest.main(StoredTest.java:29)
>>>
>>
>> Ok.. the problem is that your resultset has no metadata attached.. (it's 
>> null)  Notice "ResultSetMetaData.getColumnCount(...)"
>>
>> I have never used this syntax.. (row.getObject(..)) so I'm not familiar 
>> with what it returns. I would research this first.. It could be a jdbc 
>> implementation issue.. (contact Postgresql folks.. maybe..??)
>>
>> John...
>>
>>
>>> This is the code:
>>> ResultSet rs1 = (ResultSet) row.getObject("ref");
>>>     StorageDataSet pd=new StorageDataSet();
>>>     db.resultSetToDataSet(pd,rs1);
>>>  while (pd.next()) {
>>>           System.out.println(pd.getString(3));
>>>    }
>>> /*
>>> //this works
>>> while(rs1.next()) {
>>>     System.out.println(rs1.getString(3));
>>> }
>>> */
>>> Thanks
>>> Christa
>>>
>>> "John Moore (TeamB)" <jbm@microps.com> schrieb im Newsbeitrag 
>>> news:449d80af$1@newsgroups.borland.com...
>>>> It should...
>>>>
>>>> What errors are you getting.. (stacktrace.. please...)
>>>>
>>>> John...
>>>>
>>>>
>>>>
>>>>
>>>> Christa Schneider wrote:
>>>>> Thank you for the answer, but it is only a type mistake.
>>>>>
>>>>> THIS DOESN' T WORK, why?
>>>>> StorageDataSet pd=new StorageDataSet();
>>>>> db.resultSetToDataSet(pd,rs1);  //or pd = db.resultSetToDataSet(rs1);
>>>>>
>>>>> Thanks
>>>>> Christa Schneider
>>>>>
>>>>> "John Moore (TeamB)" <jbm@microps.com> schrieb im Newsbeitrag 
>>>>> news:449c3030$1@newsgroups.borland.com...
>>>>>> Christa Schneider wrote:
>>>>>>
>>>>>>> StorageDataSet pd=new StorageDataSet();
>>>>>>> db.resultSetToDataSet(ds,rs1); //or pd = db.resultSetToDataSet(rs1);
>>>>>> Try...
>>>>>>
>>>>>> StorageDataSet pd=new StorageDataSet();
>>>>>> db.resultSetToDataSet(pd,rs1);
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> =============================================
>>>>>> TeamB are volunteer helpers.  Please DO NOT REPLY VIA EMAIL!
>>>>>> Post all questions and replies to this newsgroup ONLY
>>>>>> For papers on DataExpress, Applets, JSP, and Web Development go to:
>>>>>> http://www.microps.com/mps/paperFAQ.html
>>>>>> ====================================================
>>>>>>
>>>>>
>>>> -- 
>>>> =============================================
>>>> TeamB are volunteer helpers.  Please DO NOT REPLY VIA EMAIL!
>>>> Post all questions and replies to this newsgroup ONLY
>>>> For papers on DataExpress, Applets, JSP, and Web Development go to:
>>>> http://www.microps.com/mps/paperFAQ.html
>>>> ====================================================
>>>>
>>>
>>>
>>
>> -- 
>> =============================================
>> TeamB are volunteer helpers.  Please DO NOT REPLY VIA EMAIL!
>> Post all questions and replies to this newsgroup ONLY
>> For papers on DataExpress, Applets, JSP, and Web Development go to:
>> http://www.microps.com/mps/paperFAQ.html
>> ====================================================
>>
> 
> 
> 


-- 
=============================================
TeamB are volunteer helpers.  Please DO NOT REPLY VIA EMAIL!
Post all questions and replies to this newsgroup ONLY
For papers on DataExpress, Applets, JSP, and Web Development go to:
http://www.microps.com/mps/paperFAQ.html
====================================================
Technical Details
Message-ID: <44a2f243$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!newsfeed.inode.at!reader.uucp.at!feeder02.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail
References: <449bca0b$1@newsgroups.borland.com> <449c3030$1@newsgroups.borland.com> <449c3946$1@newsgroups.borland.com> <449d80af$1@newsgroups.borland.com> <449db611@newsgroups.borland.com> <44a023aa$1@newsgroups.borland.com> <44a0ea3c$2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1073da,de14a88c3d1af0e4
X-Google-Attributes: gid1073da,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 28 Jun 2006 14:19:03 -0700
From: "John Moore (TeamB)" <jbm@microps.com>
User-Agent: Thunderbird 1.5.0.4 (Macintosh/20060516)
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.database
Subject: Re: ProcedureDataSet and resultSetToDataSet doesn't work
References: <449bca0b$1@newsgroups.borland.com> <449c3030$1@newsgroups.borland.com> <449c3946$1@newsgroups.borland.com> <449d80af$1@newsgroups.borland.com> <449db611@newsgroups.borland.com> <44a023aa$1@newsgroups.borland.com> <44a0ea3c$2@newsgroups.borland.com>
In-Reply-To: <44a0ea3c$2@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 207.137.13.178
Message-ID: <44a2f243$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1151529539 207.137.13.178 (28 Jun 2006 14:18:59 -0700)
Lines: 211
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!newsfeed.inode.at!reader.uucp.at!feeder02.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail