Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 206

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report