路径配置
.;C:\j2sdk1.5.0\lib\tools.jar;C:\j2sdk1.5.0\lib\dt.jar;D:\java;C:\j2sdk1.5.0\jre\bin\rt.jar;.;D:\jsptest\Tomcat 5.0\common\lib\servlet.jar;.C:\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar
出错信息:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /sqltest.jsp(1,4) Invalid directive
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:83)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:402)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:126)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:548)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1625)
org.apache.jasper.compiler.Parser.parse(Parser.java:173)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:247)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:149)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:135)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:243)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.12
测试程序
<%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*" contentType="text/html;charset=gb2312" %>
<html>
<body>
<% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydatabase";
//pubs 为你的数据库的
String user="sa";
String password="";
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()) { %>
您的第一个字段内容为:<%=rs.getString(1)%><br>
您的第二个字段内容为:<%=rs.getString(2)%><br>
<% } %>
<% out.print("数据库操作成功,恭喜你"); %>
<% rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
数据库3个文件被粘到:D:\jsptest\Tomcat 5.0\common\lib
SP3补丁也按完了
请各位大侠帮忙看看
----------------解决方案--------------------------------------------------------
在你的第一行使用了很多的中文空格
----------------解决方案--------------------------------------------------------
空格用中文的也不行吗? 应该可以吧,只要符号是英文状态下就可以吧! 学习中....
----------------解决方案--------------------------------------------------------
String password="";/*??????????
是你没设密码
还是 装SQL的时候用的 不是"混合登录"
如果 装SQL的时候用的 是windows 登录 把它改成
混合登录 就好了*/
----------------解决方案--------------------------------------------------------
怎么改成混合登陆啊,在程序上,请具体一点
----------------解决方案--------------------------------------------------------
企业管理器中可以新建登陆的!!
----------------解决方案--------------------------------------------------------
我没有设密码,也从微软网站上下了JDBC 驱动程序 SQL Server 2000 Driver for JDBC SP3
但是SP3补丁不是从微软网站上下的,不知道行不行
----------------解决方案--------------------------------------------------------
我认为大家讨论的是不是有点过了哟
看每看错误日志呀
错误明明说的jsp的第一行有错误的嘛
大家干嘛要扯到数据库上去呀
----------------解决方案--------------------------------------------------------
第一行是有中文空格,但是改了之后还是有这样子的错误:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:673) org.apache.jsp.sqltest_jsp._jspService(sqltest_jsp.java:78) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) com.microsoft.jdbc.sqlserver.tds.TDSConnection.(Unknown Source) com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source) com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source) com.microsoft.jdbc.base.BaseConnection.open(Unknown Source) com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source) java.sql.DriverManager.getConnection(Unknown Source) java.sql.DriverManager.getConnection(Unknown Source) org.apache.jsp.sqltest_jsp._jspService(sqltest_jsp.java:52) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
Apache Tomcat/5.0.12
----------------解决方案--------------------------------------------------------
怎么测试URL呢???
----------------解决方案--------------------------------------------------------