HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 5 in the jsp file: /connection_database.jspGenerated servlet error:
[javac] Compiling 1 source fileC:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\LiuYong\org\apache\jsp\connection_005fdatabase_jsp.java:54: illegal start of expression
<%out.print("?版?搴???ユ???!!!");
^
1 error
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:307)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:420)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:460)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:444)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:300)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:294)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
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.5
[javac] Compiling 1 source fileC:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\LiuYong\org\apache\jsp\connection_005fdatabase_jsp.java:54: illegal start of expression
<%out.print("?版?搴???ユ???!!!");
^
1 error
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:307)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:420)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:460)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:444)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:300)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:294)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
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.5
try{数据库的操作}
catch{例外}
如果你的源码没错的话.
TOMCAT_HOME设置了吗?
我设置啦:
C:\Program Files\Apache Software Foundation\Tomcat 5.0
还可以新建一个ODBC连接看看是否能连接上
还可以新建一个ODBC连接看看是否能连接上
这个没问题,企业管理器已经打开
包这个错!
<% 修改为
out.print("数据库连接成功!!!"); 好象是这里错误吧,没有测试,你自己实验看看
直接修改为
%>数据库连接成功!!!<%
可能更加好理解.
try{数据库的操作}
catch{例外}
这一步最好要做一下!
然后你试一试把你的输出效果放在server端,就是改为:<%System.out.println("数据库连接成功!!!");%>我想只要你的数据库驱动以及一些配制处理好了,连接应该是没有问题的!
try
{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null; String strClassName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String strConnUrl = "jdbc:microsoft:sqlserver://192.168.2.203:1433;DatabaseName=herovod30";
String strUserName = "sa";
String strUserPass = "manager";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); conn = DriverManager.getConnection(strConnUrl,strUserName,strUserPass);
stmt = conn.createStatement();
rs = stmt.executeQuery("select sg_id,sg_name from sys_group"); while (rs.next())
{
out.println("getString(2):");
out.println(rs.getString(2));
} rs.close();
stmt.close();
conn.close();
}
catch(ClassNotFoundException e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}希望对你有所帮助。
<%//可以修改的参数
String ls_username = "sa"; //数据库用户名
String ls_password = "800710"; //密码
String ls_server = "127.0.0.1:1433;DatabaseName";
String ls_dbname = "tm_demo";
Connection con = null;
Statement Stmt = null;
ResultSet rs = null;
try
{
System.out.println("Start!");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println("JDBC Regist Successfully!");
}
catch(Exception e)
{
System.out.println("Error For JDBC!");
System.out.println(e.toString());
}
try
{
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://"+ls_server+"="+ls_dbname,ls_username,ls_password);
}
catch(Exception e)
{
System.out.println("Error For Connection!");
System.out.println(e.toString());
}
我不要下面这三句就没问题??
//Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
//String sql="select * from zd_xl";
//ResultSet rs=stmt.executeQuery(sql);
%>
<%out.print("数据库连接成功!!!");%>
<html>
<head>
<title>测试数据库连接</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
microsoft网站信息
下载
Setup.exe
6.9 MB 可执行文件
33 分钟 @ 28.8 Kbps
Mssqlserver.tar
5.9 MB 可执行文件
29 分钟 @ 28.8 Kbps
阅读文档
Install.txt
1 KB 文本文件
<1 min @ 28.8 Kbps
SQL Server 2000 JDBC Driver是最好的 Type 4 JDBC驱动程序,它提供了面向企业的、与Java环境的高度可靠、高度可伸缩的连通性。SQL Server 2000 JDBC Driver为所有Java小程序(Java-enabled Applet)、应用程序或者应用程序服务器提供了JDBC访问能力。它跨越Internet和Intranet提供了对SQL Server 2000的高性能点对点访问和n层(n-tier)访问。该驱动程序针对Java环境进行了优化,使您可以将Java技术与现有的系统相结合,以扩展现有系统的功能和性能。 SQL Server 2000 JDBC Driver是一个遵从JDBC 2.0规范的驱动程序。它还支持JDBC 2.0 Optional Package的一个子集,该子集提供了以下一些功能(详细信息参见文档): Java命名目录接口(JNDI),用于命名数据源
连接池(Connection Pooling)
SQL Server 2000 JDBC Driver 支持的SQL Server版本有: SQL Server 2000.
SQL Server 2000 with Service Pack 1
以下操作系统支持SQL Server 2000 JDBC Driver: Windows XP
Windows 2000 with Service Pack 2
AIX
HP-UX
Solaris
Linux
SQL Server 2000 JDBC Driver支持以下版本的JDK: JDK 1.1.8
JDK 1.2
JDK 1.3 *********************是不是我的jdk太高。??????您可以使用新闻组对该产品进行端到端的讨论、报告程序错误或者询问其它任何相关问题。该产品当前处于beta测试过程,而且只通过新闻组进行技术支持。 安装指导 点击链接将Setup.exe(针对基于Microsoft Windows的系统)或Mssqlserver.tar(针对基于UNIX的系统)下载到您的计算机上。
点击链接将Install.txt文件下载到您的计算机上。
遵照Install.txt文件中的指令进行以后的操作。
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
当然出错.
这是我的猜想.如何证实应该很简单:)
good luck!