I will install JDK and Tomcat first, and I have been tested, and I will install the SQL Server 2000 for JDBC driver. For example, the installation directory is d: / sqldriverforjdbc, and then the three JAR files in the LIB directory in the installation directory MSBase.jar, MSSQLServer .jar, msutil.jar Copy to the Tomcat directory under the common / lib directory, then modify the classpath in the environment variable, put the D: /SQLDRiverForjdbc/lib/msbase.jar in the SQL Server 2000 for JDBC driver installation directory; D : /Sqldriverforjdbc/lib/mssqlser.jar; d: /sqldriverforjdbc/msutil.jar; Add to ClassPath, modified ClassPath as follows: ClassPath = D: / java / bin;; D: / Java / lib; : /Java/lib/dt.jar; d: /java/lib/tools.jar; d: /lubeetomcat/common/lib/servlet.jar; d: /sqldriverforjdbc/lib/msbase.jar; d: / sqldriverforjdbc / LIB / MSSQLServer.jar; d: /sqldriverforjdbc/msutil.jar Restart Tomcat! Write a simple JSP code to test the connection SQL Server 2000
<% @ Page import = "java.lang. *, Java.io. *, Java.sql. *, Java.util. *" Contenttype = "text / html; charSet = GB2312"%>
<% Class.forname ("com.microsoft.jdbc.sqlser.sqlserverdriver). NewInstance (); string url =" JDBC: Microsoft: SQLServer: // localhost: 1433; databasename = PUBS "; // Pubs for you String user database = "sa"; String password = "admin"; Connection conn = DriverManager.getConnection (url, user, password); Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); String sql = " SELECT JOB_ID, JOB_DESC from Jobs "; ResultSet RS = Stmt.executeQuery (SQL); while (rs.next ()) {%> Your first field content is: <% = rs.getstring (1)%> < BR> Your second field content is: <% = rs.getstring (2)%>Save the above JSP code as SQL_TEST.JSP, put it in the Tomcat / WebApps / root directory. Enter: http:// localhost: 8080 / sql_test.jsp, but the following error appears: Description the server encountered an internal error () That prevented it from fulfilling this request
Exception Javax.Servlet.ServletException: [Microsoft] [SQLServer 2000 Driver for JDBC] [SQLServer] User 'SA' Login failed. Cause: Not associated with trusted SQL Server connections.
Org.apache.jasper.Runtime.pageContextImpl.doHandLePageException (pageContextimpl.java: 825)
and many more. Ask you to see where you are wrong. Wait or sometimes it does not open the page. Ask you to see where you are wrong.