当前位置: 技术问答>java相关
一个很简单的JSP+JAVABEAN的问题
来源: 互联网 发布时间:2015-02-19
本文导语: 系统WIN2000+IIS5+RESIN+SQLSERVER7 javabean的编译没有问题 我想应该出在sqlserver的调用上,因为我用access测试可以,请指教 dbjsp.java代码 package test; import java.sql.*; import java.lang.String; public class dbjsp { String sDBDriver = ...
系统WIN2000+IIS5+RESIN+SQLSERVER7
javabean的编译没有问题
我想应该出在sqlserver的调用上,因为我用access测试可以,请指教
dbjsp.java代码
package test;
import java.sql.*;
import java.lang.String;
public class dbjsp {
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:jsp";
Connection conn = null;
ResultSet rs = null;
public dbjsp() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("dbjsp(): " + e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr,"lijian","123456");
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
public void update(String sql){
try {
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}
}
dbjsp.jsp代码
kehudiaocha
错误页面
500 Servlet Exception
java.lang.IllegalArgumentException
at com.caucho.xml.QName.(QName.java:59)
at com.caucho.xml.QDocument.createName(QDocument.java:434)
at com.caucho.xml.QDocument.createElement(QDocument.java:201)
at com.caucho.jsp.JspParser.parseOpenTag(JspParser.java:731)
at com.caucho.jsp.JspParser.parseNode(JspParser.java:371)
at com.caucho.jsp.JspParser.parseJsp(JspParser.java:289)
at com.caucho.jsp.JspParser.parse(JspParser.java:187)
at com.caucho.jsp.JspParser.parse(JspParser.java:135)
at com.caucho.jsp.JspManager.createPage(JspManager.java:122)
at com.caucho.jsp.PageManager.getPage(PageManager.java:334)
at com.caucho.jsp.PageManager.getPage(PageManager.java:191)
at com.caucho.jsp.QServlet.getPage(QServlet.java:214)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:126)
at com.caucho.server.http.Invocation.service(Invocation.java:273)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:128)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:216)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Resin 2.0.0 (built Fri Jun 8 12:04:24 PDT 2001)
javabean的编译没有问题
我想应该出在sqlserver的调用上,因为我用access测试可以,请指教
dbjsp.java代码
package test;
import java.sql.*;
import java.lang.String;
public class dbjsp {
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:jsp";
Connection conn = null;
ResultSet rs = null;
public dbjsp() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("dbjsp(): " + e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr,"lijian","123456");
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
public void update(String sql){
try {
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}
}
dbjsp.jsp代码
kehudiaocha
错误页面
500 Servlet Exception
java.lang.IllegalArgumentException
at com.caucho.xml.QName.(QName.java:59)
at com.caucho.xml.QDocument.createName(QDocument.java:434)
at com.caucho.xml.QDocument.createElement(QDocument.java:201)
at com.caucho.jsp.JspParser.parseOpenTag(JspParser.java:731)
at com.caucho.jsp.JspParser.parseNode(JspParser.java:371)
at com.caucho.jsp.JspParser.parseJsp(JspParser.java:289)
at com.caucho.jsp.JspParser.parse(JspParser.java:187)
at com.caucho.jsp.JspParser.parse(JspParser.java:135)
at com.caucho.jsp.JspManager.createPage(JspManager.java:122)
at com.caucho.jsp.PageManager.getPage(PageManager.java:334)
at com.caucho.jsp.PageManager.getPage(PageManager.java:191)
at com.caucho.jsp.QServlet.getPage(QServlet.java:214)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:126)
at com.caucho.server.http.Invocation.service(Invocation.java:273)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:128)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:216)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Resin 2.0.0 (built Fri Jun 8 12:04:24 PDT 2001)
|
1.下面这一句放到最开头
可以去掉language="java"
2.下面这一句有错
应该为
可以去掉language="java"
2.下面这一句有错
应该为
|
我这样就行了:test 改为 wdd
kehudiaocha
abcd
kehudiaocha
abcd
|
你那段代码在main函数里运行试试。其实除了JSP语法错误,一般都可以将JSP里的JAVA代码放到Java程序的main函数中调试。