Microsoft KB Archive/894563

= FIX: You receive a java.lang.StackOverFlowError exception when you execute lots of PRINT statements through the SQL Server 2000 Driver for JDBC =

Article ID: 894563

Article Last Modified on 10/7/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Driver for JDBC

-





SYMPTOMS
If you execute lots of PRINT statements through the Microsoft SQL Server 2000 Driver for JDBC, you may receive a java.lang.StackOverFlowError exception when the statements call the getWarnings method.



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next SQL Server 2000 Driver for JDBC service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question. The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.  Date         Time   Version   Size     File name -- 15-Nov-2004  14:29  2.2.0044  287,110  Msbase.jar 15-Nov-2004 14:29  2.2.0044   67,287  Mssqlserver.jar 15-Nov-2004 14:29  2.2.0044   59,192  Msutil.jar



WORKAROUND
To work around this bug, increase the Java Virtual Machine (JVM) stack size to allow for more warnings. To do this, type java -? at a command prompt for a list of available options for your JVM.

Note You may still experience this bug if the number of warnings exceeds the available stack space.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the behavior
Compile and then run the following Java code: import java.sql.*; public class Test {   public static void main(String[] args) throws Exception {       Connection conn = null; int number = 5000; boolean crash = false; try {           Class.forName(&quot;com.microsoft.jdbc.sqlserver.SQLServerDriver&quot;);

String url = &quot;jdbc:microsoft:sqlserver://:1433;DatabaseName=master;&quot;; conn = DriverManager.getConnection(url, &quot;&quot;, &quot;&quot;); conn.setReadOnly(true); // Loop until the fixed limit is reached. while(true && (number < 50000)) {               // Generate SQL code. System.out.println(&quot;\nGenerating &quot; + number + &quot; statements in memory.&quot;); StringBuffer sb = new StringBuffer(&quot;BEGIN TRANSACTION\n&quot;); for (int i=0; i<number; i++) {                   sb.append(&quot;PRINT 'Hello world !'\n&quot;); }               sb.append(&quot;COMMIT TRANSACTION\n&quot;); // Execute code. System.out.println(&quot;Executing code.&quot;); conn.clearWarnings; Statement stmt = conn.createStatement; stmt.execute(sb.toString); // Get warnings. System.out.println(&quot;Retrieving warning messages.&quot;); crash = true; SQLWarning warnings = stmt.getWarnings; crash = false; System.out.println(&quot;Retrieved all warnings succesfully!&quot;); // Increase the number of PRINT statements to send. number += 1000; }       }        catch(Exception e)         { e.printStackTrace; }       finally {           if(conn != null) {               conn.close; }       }

System.out.println(&quot;\nEnded with &quot; + (crash ? &quot;crash on &quot; + number + &quot; statements processing!&quot; : &quot;no errors.&quot;)); } } Note In this code, replace,  , and   in this code with the name of your computer that is running SQL Server, your user ID, and your password.

