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
- Package com. database;
- Import java. SQL .*;
- Public class DbConn {
- // Private static StringDriverName="Com. microsoft. jdbc. sqlserver. SQLServerDriver";
- // Private static StringDbURL="Jdbc: microsoft: sqlserver: // localhost: 1433; DatabaseName = jsp";
- // The original connection, jsp is the database file http://www.dwww.cn
- Private static StringDriverName="Net. sourceforge. jtds. jdbc. Driver";
- Private static StringDbURL="Jdbc: jtds: sqlserver: // localhost: 1433/jsp";
- Private StringUserName="Dwww";
- Private StringUserPwd="Dwww";
- Public ConnectionDbConn=Null;
- Public synchronized Connection getConnection ()
- {
- Try
- {
- Class. forName (driverName). newInstance ();
- DbConn=DriverManager. GetConnection (dbURL, userName, userPwd );
- If (dbConn! = Null)
- Return dbConn;
- }
- Catch (Exception e)
- {
- E. printStackTrace ();
- Return null;
- }
- Return null;
- }
- }
OK. Solve the driver conflict in JSP website development.
- Notes for connecting JSP to ORACLE databases
- Configuration of tomcat SQL Server2000 Database Connection Pool in JSP
- Differences between Servlets and JSP
- Differences between JSP include commands and include actions
- Solutions to JSP output of excel documents and Chinese garbled characters