main(String[] args) Test that output result sets, return values and output parameters are
correctly handled for a remote procedure call.
To set up this test you will a local and remote server where the remote
server allows logins from the local test server.
Install the following stored procedure on the remote server:
create proc jtds_remote @in varchar(16), @out varchar(32) output as
begin
select 'result set'
set @out = 'Test ' + @in;
return 1
end
Uncomment this test and amend the remoteserver name in the prepareCall
statement below to be the actual name of your remote server.
The TDS stream for this test will comprise a result set, a dummy return
(0x79) value and then the actual return and output parameter (0xAC) records.
This call will fail with jtds 1.1 as the dummy return value of 0 in the
TDS stream will preempt the capture of the actual value 1.
public void
testBigDecimal() Test for bug [1236078] Procedure doesn't get called for some BigDecimal
values - invalid bug.
testCallableStatementParsing6() Test for incorrect exception thrown/no exception thrown when invalid
call escape is used.
public void
testCallableStatementParsing7() Test for incorrect exception thrown/no exception thrown when invalid
call escape is used.
public void
testErrorOutputParams() Test for bug [1047208] SQLException chaining not implemented correctly:
checks that all errors are returned and that output variables are also
returned.
testNonRpcProc1() Test that procedure calls with both literal parameters and parameterr
markers are executed correctly (bug [1078927] Callable statement fails).
public void
testNonRpcProc2() Test that procedure calls with both literal parameters and parameterr
markers are executed correctly (bug [1078927] Callable statement fails).
public void
testProcessUpdateCounts1() Test that procedure outputs are available immediately for procedures
that do not return ResultSets (i.e that update counts are cached).
public void
testProcessUpdateCounts2() Test that procedure outputs are available immediately after processing
the last ResultSet returned by the procedure (i.e that update counts
are cached).
public void
testProcessUpdateCounts3() Test that procedure outputs are available immediately after processing
the last ResultSet returned by the procedure (i.e that update counts
are cached) even if getMoreResults() is not called.
public void
testProcessUpdateCounts4() Test that procedure outputs are available immediately after processing
the last ResultSet returned by the procedure (i.e that update counts
are cached) even if getMoreResults() and ResultSet.close() are not
called.
public void
testSemicolonProcedures() Test that procedure names containing semicolons are parsed correctly.
testWritetext() Test for bug [1152329] Spurious output params assigned (TIMESTMP).
If a stored procedure execute WRITETEXT or UPDATETEXT commands, spurious
output parameter data is returned to the client.
Test that output result sets, return values and output parameters are
correctly handled for a remote procedure call.
To set up this test you will a local and remote server where the remote
server allows logins from the local test server.
Install the following stored procedure on the remote server:
create proc jtds_remote @in varchar(16), @out varchar(32) output as
begin
select 'result set'
set @out = 'Test ' + @in;
return 1
end
Uncomment this test and amend the remoteserver name in the prepareCall
statement below to be the actual name of your remote server.
The TDS stream for this test will comprise a result set, a dummy return
(0x79) value and then the actual return and output parameter (0xAC) records.
This call will fail with jtds 1.1 as the dummy return value of 0 in the
TDS stream will preempt the capture of the actual value 1. In addition the
return value will be assigned to the output parameter and the actual output
parameter value will be lost.
public void testRemoteCallWithResultSet() throws Exception {
CallableStatement cstmt = con.prepareCall(
"{?=call remoteserver.database.user.jtds_remote(?,?)}");
cstmt.registerOutParameter(1, Types.INTEGER);
cstmt.setString(2, "data");
cstmt.registerOutParameter(3, Types.VARCHAR);
cstmt.execute();
ResultSet rs = cstmt.getResultSet();
assertNotNull(rs);
assertTrue(rs.next());
assertEquals("result set", rs.getString(1));
assertFalse(rs.next());
rs.close();
assertEquals(1, cstmt.getInt(1));
assertEquals("Test data", cstmt.getString(3));
cstmt.close();
}
Test for incorrect exception thrown/no exception thrown when invalid
call escape is used.
See https://sourceforge.net/forum/forum.php?thread_id=1144619&forum_id=104389
for more detail.
testCallableStatementParsing5
public void testCallableStatementParsing5() throws Exception(Code)
Test for bug [1052942] Error processing JDBC call escape. (A blank
before the final } causes the parser to fail).
Test for incorrect exception thrown/no exception thrown when invalid
call escape is used.
A message containing the correct missing terminator should be generated.
Test for incorrect exception thrown/no exception thrown when invalid
call escape is used.
A message containing the correct missing terminator should be generated.
Test for bug [1047208] SQLException chaining not implemented correctly:
checks that all errors are returned and that output variables are also
returned.
Test that procedure outputs are available immediately after processing
the last ResultSet returned by the procedure (i.e that update counts
are cached).
Test that procedure outputs are available immediately after processing
the last ResultSet returned by the procedure (i.e that update counts
are cached) even if getMoreResults() is not called.
Test that procedure outputs are available immediately after processing
the last ResultSet returned by the procedure (i.e that update counts
are cached) even if getMoreResults() and ResultSet.close() are not
called.
testSemicolonProcedures
public void testSemicolonProcedures() throws Exception(Code)
Test that procedure names containing semicolons are parsed correctly.
Test for bug [1152329] Spurious output params assigned (TIMESTMP).
If a stored procedure execute WRITETEXT or UPDATETEXT commands, spurious
output parameter data is returned to the client. This additional data
can be confused with the real output parameter data leading to an output
string parameter returning the text ?TIMESTMP? on SQL Server 7+ or
binary garbage on other servers.
Fields inherited from net.sourceforge.jtds.test.TestBase