当前位置: 技术问答>java相关
100分给了,请教多人,未能解决!!!
来源: 互联网 发布时间:2017-04-06
本文导语: index.html 代码如下: index.htm 飞鸿留言版 飞鸿驿站 姓名: 电子邮件: 个人主页地址: 请您留言 index.jsp 代码如下: 现在有 条纪录 昵称: ...
index.html
代码如下:
index.htm
飞鸿留言版
姓名:
代码如下:
index.htm
飞鸿留言版
飞鸿驿站
姓名:
电子邮件:
个人主页地址:
请您留言
index.jsp
代码如下:
现在有 条纪录
昵称:
电子邮件:
个人主页地址:
内容:
sql.java
代码如下:
import java.sql.*;
public class sql_data
{
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:guestbook";
Connection conn = null;
ResultSet rs = null;
public sql_data()
{
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("sql_data(): " + e.getMessage());
}
}
public void executeInsert(String sql)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("sql_data.executeUpdate:"+ex.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
rs = null;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.err.println("sql_data.executeQuery:"+ex.getMessage());
}
return rs;
}
public void executeDelete(String sql)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("sql_data.executeDelete:"+ex.getMessage());
}
}
}
请高手帮我让这个jsp网页可以运行,在我机子上无法运行。我的tomact应该没问题。主页可以打开。而且例子可以运行。我用的是tomact4.0.我编的是后台为sql server2000数据库。系统dsn我也建了为guestbook.
而且我用javac sql.java 后,出现:sql.java:2:class sql_data is public,should be daclared in a file named sql_data.java
public class sql_data 1 error
然后我把sql.java,改名为sql_data.java后编译成功,出现了sql_data.class的文件,我把sql_data.class,sql_data.java拷到D:Program FilesApache Tomcat 4.0webappsexamplesWEB-INFclasses下,然后运行出现以下状况:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
D:Program FilesApache Tomcat 4.0workStandalonelocalhostexamplesjspsqlindex$jsp.java:4: Class sql not found in import.
import sql;;
^
D:Program FilesApache Tomcat 4.0workStandalonelocalhostexamplesjspsqlindex$jsp.java:5: Class or interface declaration expected.
import javax.servlet.*;
^
D:Program FilesApache Tomcat 4.0workStandalonelocalhostexamplesjspsqlindex$jsp.java:11: Superclass org.apache.jsp.HttpJspBase of class org.apache.jsp.index$jsp not found.
public class index$jsp extends HttpJspBase {
^
3 errors
请诸位高手帮小弟解决一下,小弟已经忙了一天了。实在是头疼。小弟是菜鸟!!!!解决后,小弟定给高分。
还有的是我在tomact中运行书上说的例子总是出现
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
D:Program FilesApache Tomcat 4.0workStandalonelocalhostexamplesjspliusebean$jsp.java:4: Class or interface declaration expected.
import javax.servlet.*;
^
D:Program FilesApache Tomcat 4.0workStandalonelocalhostexamplesjspliusebean$jsp.java:10: Superclass org.apache.jsp.HttpJspBase of class org.apache.jsp.usebean$jsp not found.
public class usebean$jsp extends HttpJspBase {
2errors
可是我运行tomact4.0中的例子没问题。
|
是啊!
ODBC设置正确了吗?SQL语句写正确了吗?操纵的表存不存在或者访问的字段存不存?你确定你建立的表跟书上说的一样吗(字段类型、长度)?
ODBC设置正确了吗?SQL语句写正确了吗?操纵的表存不存在或者访问的字段存不存?你确定你建立的表跟书上说的一样吗(字段类型、长度)?
|
好了,我要下了.虽然我不算JSP高手,但也摆弄JSP蛮长时间了。我的邮箱是
badhunters2002@yahoo.com.cn
badhunters2002@yahoo.com.cn