freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
FW: JDBC-Gurus, please comment: sorry, better code:
- From: "Schörk, Andreas" <andreas.schoerk AT infor.de>
- To: "TDS Development Group (E-mail)" <freetds AT franklin.oit.unc.edu>
- Subject: FW: JDBC-Gurus, please comment: sorry, better code:
- Date: Fri, 14 Sep 2001 16:58:34 +0200
After some checks I saw that my code could not work.
Now I use execute instead of executeQuery, which is
supposed to only return one ResultSet.
btw. should it search for the first one and deliver
this or should it executeQuery fail if the first statement
is an not resultset delivering ??
-----Original Message-----
From: "Schörk, Andreas" [mailto:andreas.schoerk AT infor.de]
Sent: Freitag, 14. September 2001 09:23
To: TDS Development Group
Subject: [freetds] JDBC-Gurus, please comment
Hello,
could anybody put some effort into looking through the junit code below and
tell me
whether this is ok, I am also interested in experiences, how you think that
other
mssql-jdbc-drivers are handling this:
Andreas
first Antons Proc:
stmt.executeUpdate(" create procedure spTestExec2 as " +
"select 'Did it work?' as Result");
stmt.executeUpdate("create procedure spTestExec as " +
"set nocount off " +
"create table #tmp ( Result varchar(50) ) " +
"insert #tmp execute spTestExec2 " +
"select * from #tmp");
CallableStatement cstmt = con.prepareCall("spTestExec");
assertTrue(!cstmt.execute());
assertTrue(cstmt.getUpdateCount() == 0); // set
assertTrue(!cstmt.getMoreResults());
assertTrue(cstmt.getUpdateCount() == 0); // create
assertTrue(!cstmt.getMoreResults());
assertTrue(cstmt.getUpdateCount() == 0); // execute
assertTrue(!cstmt.getMoreResults());
assertTrue(cstmt.getUpdateCount() == 1); // insert
assertTrue(cstmt.getMoreResults());
ResultSet rs = cstmt.getResultSet();
while (rs.next()) {
passed = true;
}
assertTrue(!cstmt.getMoreResults() && cstmt.getUpdateCount() == -1);
Now some coming from a twisted mind:
String sqlwithcount2 =
"create procedure multi1withcount as " +
" set nocount off " +
" select 'a' " +
" select 'b' " +
" create table #multi1withcountt (A VARCHAR(20)) " +
" insert into #multi1withcountt VALUES ('a') " +
" insert into #multi1withcountt VALUES ('a') " +
" insert into #multi1withcountt VALUES ('a') " +
" select 'a' " +
" select 'b' ";
stmt.executeUpdate(sqlnocount2);
CallableStatement cstmt = con.prepareCall("multi1nocount");
assertTrue(cstmt.execute());
ResultSet rs = cstmt.getResultSet();
Statement s2 = cstmt;
assertTrue(rs.next());
assertTrue(rs.getString(1).equals("a"));
assertTrue(!rs.next());
assertTrue(s2.getMoreResults());
rs = s2.getResultSet();
assertTrue(rs.next());
assertTrue(rs.getString(1).equals("b"));
assertTrue(!rs.next());
assertTrue(s2.getMoreResults());
rs = s2.getResultSet();
assertTrue(rs.next());
assertTrue(!rs.next());
assertTrue(s2.getMoreResults());
rs = s2.getResultSet();
assertTrue(rs.next());
assertTrue(!rs.next());
assertTrue(!s2.getMoreResults() && s2.getUpdateCount() == -1);
---
You are currently subscribed to freetds as: [andreas.schoerk AT infor.de]
To unsubscribe, forward this message to
$subst('Email.Unsub')
- FW: JDBC-Gurus, please comment: sorry, better code:, Schörk, Andreas, 09/14/2001
Archive powered by MHonArc 2.6.24.