Microsoft KB Archive/895467

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

Article ID: 895467

Article Last Modified on 3/23/2005

-

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_ .tmp
 * Scb_ .tmp

Note  and   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.



Steps to reproduce the behavior
  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(&quot;com.microsoft.jdbc.sqlserver.SQLServerDriver&quot;);

Connection con = DriverManager.getConnection(&quot;jdbc:microsoft:sqlserver://:1433;SelectMethod=cursor;DatabaseName=Northwind&quot;, &quot;&quot;,&quot;&quot;); DatabaseMetaData md = con.getMetaData;

String catalog = null; String schema = null; String table  = &quot;Customers&quot;;

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(&quot;=================================================================&quot;); 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(&quot;, &quot;); }               System.out.println(&quot;&quot;); while(rs.next) {                   r++; System.out.print(&quot;Row: &quot; + r + &quot;: &quot;); for(int i=1; i <= numOfColumns; i++ ) {                       System.out.print(rs.getString(i)); if(i != numOfColumns) System.out.print(&quot;, &quot;); }                   System.out.println(&quot;&quot;); }           }            catch (SQLException e)            { e.printStackTrace; }       }    }

Note To use the code example, replace  ,  , and   with the name of your computer that is running SQL Server, your user id, and your password.  From Explorer, locate the C:\Documents and Settings\ \Local Settings\Temp folder to view the scb_ .tmp and the srt_ .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

Keywords: kbbug kbdatabase kbjava kbjdbc KB895467

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.