package book;
import java.util.*;
import java.sql.*;public class book
{
private ResultSet rs = null;
private Statement stmt = null;
private Connection con = null; public void openDate(String url, String us, String ps)
{
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection(url, us, ps);
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
}
catch (Exception e)
{
e.printStackTrace();
}
} public void closeDate()
{
try
{
stmt.close();
con.close();
}
catch (Exception e)
{
e.printStackTrace();
}
} public ResultSet secrchSql(String sql)
{
try
{
rs = stmt.executeQuery(sql);
}
catch (Exception e)
{
e.printStackTrace();
}
return (rs);
} public void editSql(String sql)
{
try
{
stmt.executeUpdate(sql);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}解决给分!我确保数据库没问题!
就是这个JAVA文件生成的CLASS文件用JSP连接时错误!我保证CLASS的包和文件的位置对!
问题在这个JAVA程序本身!
import java.util.*;
import java.sql.*;public class book
{
private ResultSet rs = null;
private Statement stmt = null;
private Connection con = null; public void openDate(String url, String us, String ps)
{
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection(url, us, ps);
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
}
catch (Exception e)
{
e.printStackTrace();
}
} public void closeDate()
{
try
{
stmt.close();
con.close();
}
catch (Exception e)
{
e.printStackTrace();
}
} public ResultSet secrchSql(String sql)
{
try
{
rs = stmt.executeQuery(sql);
}
catch (Exception e)
{
e.printStackTrace();
}
return (rs);
} public void editSql(String sql)
{
try
{
stmt.executeUpdate(sql);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}解决给分!我确保数据库没问题!
就是这个JAVA文件生成的CLASS文件用JSP连接时错误!我保证CLASS的包和文件的位置对!
问题在这个JAVA程序本身!
public class Book { ...包名和类名不应该相同。
[javac] Compiling 1 source fileC:\Tomcat 4.1\work\Standalone\localhost\_\liuyan\board_jsp.java:90: illegal character: \65307
sql = "select * from message"锛?
^An error occurred at line: 24 in the jsp file: /liuyan/board.jspGenerated servlet error:
C:\Tomcat 4.1\work\Standalone\localhost\_\liuyan\board_jsp.java:91: illegal character: \65307
rst = GO.secrchSql(sql)锛? //璋???芥??ヨ??版?搴?
^An error occurred at line: 24 in the jsp file: /liuyan/board.jspGenerated servlet error:
C:\Tomcat 4.1\work\Standalone\localhost\_\liuyan\board_jsp.java:106: illegal character: \65307
rst = GO.secrchSql(sql)锛? //璋???芥??ヨ??版?搴?
^An error occurred at line: 10 in the jsp file: /liuyan/board.jspGenerated servlet error:
C:\Tomcat 4.1\work\Standalone\localhost\_\liuyan\board_jsp.java:54: package book does not exist
book.book GO = null;
^An error occurred at line: 10 in the jsp file: /liuyan/board.jspGenerated servlet error:
C:\Tomcat 4.1\work\Standalone\localhost\_\liuyan\board_jsp.java:56: package book does not exist
GO = (book.book) pageContext.getAttribute("GO", PageContext.REQUEST_SCOPE);
^An error occurred at line: 10 in the jsp file: /liuyan/board.jspGenerated servlet error:
C:\Tomcat 4.1\work\Standalone\localhost\_\liuyan\board_jsp.java:59: package book does not exist
GO = (book.book) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "book.book");
^An error occurred at line: 24 in the jsp file: /liuyan/board.jspGenerated servlet error:
C:\Tomcat 4.1\work\Standalone\localhost\_\liuyan\board_jsp.java:84: cannot resolve symbol
symbol : method GO (java.lang.String,java.lang.String,java.lang.String)
location: class org.apache.jsp.board_jsp
GO(url, user, password);
^
7 errors