BUG: Calling the DatabaseMetaData.getPrimaryKeys function generates lots of temporary files when you use the SQL Server 2000 Driver for JDBC (895467)



The information in this article applies to:

  • Microsoft SQL Server 2000 Driver for JDBC

SYMPTOMS

When you try to call the DatabaseMetaData.getPrimaryKeys function by using the Microsoft SQL Server 2000 Driver for JDBC, you may notice that two temporary files are saved to the Temp folder. Because these temporary files are never deleted, the number of files in the Temp folder increases quickly.

For each execution of the code, the following two temporary files are created:

  • Srt_XXXXX.tmp
  • Scb_YYYYY.tmp

    Note XXXXX and YYYYY are placeholders that represent numbers.

WORKAROUND

To work around this issue, explicitly close all the result sets and all the statements in the Java code. The SQL Server 2000 Driver for JDBC can then delete the associated temporary files.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior


  1. Compile and run the following Java code.
    import java.*;
    	import java.sql.*;
    	import java.util.*; 
    	import java.text.*;
    
    	public class Test
    	{
    		public static void main(String[] args) throws Exception
    		{
    			Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    
    			Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://<Server>:1433;SelectMethod=cursor;DatabaseName=Northwind", "<UserId>","<PassWd>");
    			DatabaseMetaData md = con.getMetaData();
    
    		        String catalog = null;
    		        String schema  = null;
    		        String table   = "Customers";
    
    			ResultSet rs = md.getPrimaryKeys(catalog, schema, table);
    			displayRows(rs);
    
    			// Cleanup
    			md=null;
    			con.close();
    			con=null;
    		}
    
    		public static void displayRows(ResultSet rs)
    		{
    			try
    			{
    				System.out.println("=================================================================");
    				ResultSetMetaData rsmd = rs.getMetaData();
    				int numOfColumns = rsmd.getColumnCount();
    				int r = 0;
    
    				for(int i=1; i <= numOfColumns; i++ )
    				{
    					System.out.print(rsmd.getColumnLabel(i));
    					if(i != numOfColumns)
    						System.out.print(" , ");
    				}
    				System.out.println("");
    				while(rs.next())
    				{
    					r++;
    					System.out.print("Row: " + r + ": ");
    					for(int i=1; i <= numOfColumns; i++ )
    					{
    						System.out.print(rs.getString(i));
    						if(i != numOfColumns)
    							System.out.print(" , ");
    					}
    					System.out.println("");
    				}
    			}
    			catch (SQLException e)
    			{
    				e.printStackTrace();
    			}
    		}
    	}
    

    Note To use the code example, replace Server, UserId, and PassWd with the name of your computer that is running SQL Server, your user id, and your password.
  2. From Explorer, locate the C:\Documents and Settings\Username\Local Settings\Temp folder to view the scb_YYYYY.tmp and the srt_XXXXX.tmp files. A pair of files is created for each execution of the Java code.

    Note The specific Temp folder may be in a different location. For example, the temporary folder may be in C:\Winnt\Temp. Therefore, you may have to search the hard disk drive for the specific location of the Temp folder.

For more information about Java Database Connectivity (JDBC), click the following article number to view the article in the Microsoft Knowledge Base:

313100 How to get started with Microsoft JDBC


For more information about the standard terminology that is used to describe Microsoft software updates, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates


Modification Type:MajorLast Reviewed:3/23/2005
Keywords:kbDatabase kbJava kbJDBC kbbug KB895467 kbAudDeveloper