Skip to Content.
Sympa Menu

freetds - JDBC-Gurus, please comment

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Schörk, Andreas" <andreas.schoerk AT infor.de>
  • To: "TDS Development Group (E-mail)" <freetds AT franklin.oit.unc.edu>
  • Subject: JDBC-Gurus, please comment
  • Date: Fri, 14 Sep 2001 09:23:09 +0200


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("exec multi1nocount");
ResultSet rs = cstmt.executeQuery();
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);






Archive powered by MHonArc 2.6.24.

Top of Page