Solve driver conflicts in JSP website development

Source: Internet
Author: User

Enthusiastic people on the network summarized the disadvantages of Microsoft-driven JSP website development:

1) if the jdbc-odbc driver is used, the data must be read at a time in the query order, whether there is any image or text type)

2) If the ms SQL server jdbc driver provided by Microsoft is used, if the query statement does not contain an image or text field, it can be obtained unordered.

3) if the ms SQL server jdbc driver provided by Microsoft is used and an image or text field exists in the query statement, it must be read in order, otherwise, an error 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 retrieve them in different order or repeatedly. The driver must be replaced and switched to a third party.

Solution:

Download JDTS driver support SQL6.5, 7.0, SYBASE): http://jtds.sourceforge.net/

Download and unzip to find the jtds-1.2.2.jar, put the JSP project WEB-INF/lib directory

Database connection file DbConn. java

 
 
  1. Package com. database;
  2. Import java. SQL .*;
  3. Public class DbConn {
  4. // Private static StringDriverName="Com. microsoft. jdbc. sqlserver. SQLServerDriver";
  5. // Private static StringDbURL="Jdbc: microsoft: sqlserver: // localhost: 1433; DatabaseName = jsp";
  6. // The original connection, jsp is the database file http://www.dwww.cn
  7. Private static StringDriverName="Net. sourceforge. jtds. jdbc. Driver";
  8. Private static StringDbURL="Jdbc: jtds: sqlserver: // localhost: 1433/jsp";
  9. Private StringUserName="Dwww";
  10. Private StringUserPwd="Dwww";
  11. Public ConnectionDbConn=Null;
  12. Public synchronized Connection getConnection ()
  13. {
  14. Try
  15. {
  16. Class. forName (driverName). newInstance ();
  17. DbConn=DriverManager. GetConnection (dbURL, userName, userPwd );
  18. If (dbConn! = Null)
  19. Return dbConn;
  20. }
  21. Catch (Exception e)
  22. {
  23. E. printStackTrace ();
  24. Return null;
  25. }
  26. Return null;
  27. }
  28. }

OK. Solve the driver conflict in JSP website development.

  1. Notes for connecting JSP to ORACLE databases
  2. Configuration of tomcat SQL Server2000 Database Connection Pool in JSP
  3. Differences between Servlets and JSP
  4. Differences between JSP include commands and include actions
  5. Solutions to JSP output of excel documents and Chinese garbled characters

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.