问题描述
tomcat6.0怎么连接SQL2000连接之后怎么测试连接是否成功?求解答啊<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.sql.*"import="java.util.*"%><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><%try{Stringurl="jdbc:odbc:Driver={SQLServer};DBQ=E:SQL2000SQL2MSSQLDataTest_Data.MDF";Class.forName("com.micorosoft.jdbc.sqlserver.SQLServerDriver");Connectionconn=DriverManager.getConnection(url,"sa","chenjiang");Statementstmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);Stringsql="select*fromusername";ResultSetrs=stmt.executeQuery(sql);while(rs.next()){out.print("用户名:"+rs.getString("uid"));out.print("密码:"+rs.getString("pwd")+"<br>");}out.print("<br>恭喜你!数据库连接成功!");rs.close();stmt.close();conn.close();}catch(Exceptione){out.print("数据库连接错误!,错误信息如下:<br>");out.print(e.getMessage());}%>这个测试代码对于SQL2000该怎么改写啊Stringurl="jdbc:odbc:Driver={SQLServer};DBQ=E:SQL2000SQL2MSSQLDataTest_Data.MDF";Class.forName("com.micorosoft.jdbc.sqlserver.SQLServerDriver");弄了一晚上还是没弄好求帮忙打开http://localhost:8080/a.jsp就出现这些错误typeExceptionreportmessagedescriptionTheserverencounteredaninternalerror()thatpreventeditfromfulfillingthisrequest.exceptionorg.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurredatline:20inthejspfile:/a.jspInvalidescapesequence(validonesarebtnfr"'\)17:{18:19://数据库连接字符串20:Stringurl="jdbc:odbc:Driver={SQLServer};DBQ=E:SQL2000SQL2MSSQLDataTest_Data.MDF";21://加载驱动程序22:Class.forName("com.micorosoft.jdbc.sqlserver.SQLServerDriver");23://建立连接Stacktrace:org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)noteThefullstacktraceoftherootcauseisavailableintheApacheTomcat/6.0.18logs.
解决方案
本帖最后由 meideyisi 于 2010-05-11 20:17:27 编辑
解决方案二:
有补丁包吗
解决方案三:
你的jar包弄进去没
解决方案四:
有可能是jar包没有导入