Use caution or try not to use Microsoft's own JDBC driver for SQL Server

Source: Internet
Author: User
-->
-->


Microsoft will not be happy to see this headline. But to be honest, in business applications, there are few companies that really use Microsoft's com.microsoft.jdbc.sqlserver.sqlserverDriver.

In fact, it is also a chance to find out the lack of Microsoft drive. In a single porting application, the system reported errors such as [microsoft][sqlserver JDBC Driver]resultset can not re-read row data for column. To resolve this error, the tracker was busy for most of the day and did not identify the problem. Can only be determined in the rs.getstring ("XXX") when there must be errors (RS for ResultSet object). So now simulate the following environment:
database table: TestTable
Table fields and types:
GUID char (38)
Title varchar (100)
Content Text
Username varchar (20)
Query SQL statements:
Select Guid,username,content,title from testtable where
Java code:
Rs.getstring ("GUID");
Rs.getbinarystream ("content");
Rs.getstring ("username");
-----------------------------------------------------------

The above code, very not honored to be. Using the driver of Microsoft, it will certainly be an error (that is, the mistake mentioned above). If you follow it, it must be this line: rs.getstring ("username") throws an error.

So, what if you put rs.getstring ("username") and Rs.getbinarystream ("content"); The result is that you can run normally.

Why does this happen because Microsoft drives a field that contains a BLOB or CLOB type (that is, image and text type). Then you must query in the Select order and do not support duplicate queries.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.