Microsoft KB Archive/894558

= FIX: You receive an error message in SQL Server 2000 Driver for JDBC when you submit a converted SQL statement that is generated by the Connection.nativeSQL method to the SQL database. =

Article ID: 894558

Article Last Modified on 9/1/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Driver for JDBC

-





SYMPTOMS
Consider the following scenario. You use the Microsoft SQL Server 2000 Driver for JDBC to connect an application to an SQL database. Then, you use the Connection.nativeSQL method to convert an SQL statement to native SQL syntax. When you submit the converted SQL statement to the SQL database, you receive an error message. When you review the converted SQL statement that you submitted, you notice that it differs from the actual SQL statement.



CAUSE
This problem occurs because the Connection.nativeSQL method does not return the actual SQL statement that is sent to the SQL database by the SQL Server 2000 Driver for JDBC. Therefore, you may have unintentionally submitted an incorrect SQL statement to the SQL database.



RESOLUTION
To resolve this problem, obtain SQL Server 2000 Driver for JDBC Service Pack 3 (SP 3). For more information, visit the following Microsoft Web site:

http://www.microsoft.com/downloads/details.aspx?FamilyID=07287b11-0502-461a-b138-2aa54bfdc03a&DisplayLang=en



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section. This problem was corrected in SQL Server 2000 Driver for JDBC Service Pack 3.



MORE INFORMATION
For more information about 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, 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



Steps to reproduce the behavior
  To reproduce this problem, compile and then run the following code sample: import java.sql.*;

public class Class1 {   public static void main (String[] args) {       try {           Class.forName(&quot;com.microsoft.jdbc.sqlserver.SQLServerDriver&quot;); Connection c = DriverManager.getConnection(&quot;jdbc:microsoft:sqlserver://:1433&quot;, &quot;&quot;, &quot;&quot;); String strSql = &quot;select {fn convert(name,SQL_REAL)} from sysdatabases&quot;; System.out.println( c.nativeSQL(strSql) ); Statement stmt = c.createStatement; ResultSet rs = stmt.executeQuery(strSql); rs.close; stmt.close; c.close; }       catch (Exception ex) {           ex.printStackTrace; }

} } Note To use this code sample, replace the following placeholders:  Replace  by using the name of the instance of SQL Server. Replace  by using your user ID.</li> Replace  by using your password.</li></ul>

When you run this code sample, SQL Server 2000 generates the following output: select {fn convert(name,SQL_REAL)} from sysdatabases </li>  Run the output that was generated by SQL Server 2000 in step 1. When you run the output, the following SQL statement is submitted to the SQL database: SELECT {fn CONVERT(name, SQL_SQL_REAL)} FROM sysdatabases When this SQL statement is submitted to the SQL database, SQL Server 2000 generates the following error message:

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]'SQL_SQL_REAL' is not a recognized ODBC datatype option.

at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)

at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)

at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)

at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)

at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)

at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)

at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)

at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)

at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)

at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)

at com.microsoft.jdbc.base.BaseStatement.executeQuery(Unknown Source) at Class1.main(Class1.java:17)

SQL Server 2000 generates this error message because the code in the SQL statement that was submitted to the SQL database incorrectly states &quot;SQL_REAL&quot; instead of &quot;REAL.&quot; </li></ol>

Keywords: kbtshoot kbbug kbfix KB894558

-

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

© Microsoft Corporation. All rights reserved.