Get the App
SLTechnology News&Howtos  ›  Development  › 

How to deal with the ResultSet related problems caused by Microsoft driver in the development of JSP website

Shulou Source: shulou.com Published: 2022-06-02 12:23:53 09月21日 Update

Editor to share with you how to deal with the ResultSet-related problems caused by Microsoft driver in the development of JSP website. I hope you will gain something after reading this article. Let's discuss it together.

When I encountered the problem of "ResultSet can not re-read row data for column 1" in the development of JSP website (JSP+sqlserver), I found out that the compatibility of Microsoft driver was not very good.

Some enthusiasts summed up the shortcomings of Microsoft driver:

(1) if the jdbc-odbc driver is used, it must be read once according to the query order (with or without image or text type)

(2) if you use the ms sql server jdbc driver provided by Microsoft, if there is no image or text type field in the query statement, you can get it out of order.

(3) if you use ms sql server jdbc driver provided by Microsoft, if there are fields of type image or text in the query statement, you must read them in order, otherwise errors such as Driver] ResultSet can not re-read row data for column will be reported.

(4) if you do not want to query whether there are image or text fields in the statement, you can get them out of order or repeatedly. Then you must replace this Microsoft driver and use a third-party one.

Solution:

Download JDTS driver (supports SQL6.5,7.0,2000,2005,SYBASE): http://jtds.sourceforge.net/

After downloading and decompressing, find jtds-1.2.2.jar and put it in the WEB-INF/lib directory of the JSP project.

Database connection file DbConn.java

Package com.database; import java.sql.*; public class DbConn {/ / private static String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; / / private static String dbURL= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jsp"; / / original connection, jsp is the database file http://www.dwww.cn private static String driverName = "net.sourceforge.jtds.jdbc.Driver"; private static String dbURL= "jdbc:jtds:sqlserver://localhost:1433/jsp" Private String userName= "dwww"; private String userPwd= "dwww"; public Connection dbConn=null; public synchronized Connection getConnection () {try {Class.forName (driverName). NewInstance (); dbConn=DriverManager.getConnection (dbURL, userName, userPwd); if (dbConnell null) return dbConn;} catch (Exception e) {e.printStackTrace (); return null;} return null;}}

Solve Ok,ResultSet related problems.

After reading this article, I believe you have a certain understanding of "how to deal with ResultSet-related problems caused by Microsoft drivers in the development of JSP websites". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Microsoft drivers questions types queries websites website development fields statements order data databases files articles compatibility done methods more warm-hearted people Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Microsoft MySQL Shulou Information NVidia