<%@    page  contentType="text/html;charset=gb2312"%>                  
<%@    page  import="java.sql.*"%>          
<html>                  
<body>                  
<%
String driverClass="com.microsoft.jdbc.sqlserver.SQLServerDriver";
Class.forName(driverClass);                
String    url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=company";          
//statement查询操作          
String    user="sa";          
String    password="";          
Connection    conn=DriverManager.getConnection(url,user,password);                  
Statement    stmt=conn.createStatement();                  
String sql="select * from employee";                 
ResultSet    rs=stmt.executeQuery(sql); CallableStatement cs=Connection.prepareCall();
CallableStatement cs=Connection.prepareCall("{call p_insert(?,?,?,?,?,?,?,?,?,?)}");
cs.setString(1,"E0021");
cs.setString(2,"吴华");
cs.setString(3,"男");
cs.setString(4,"业务");
cs.setString(5,"职员");
cs.setString(6,"1993-04-12");
cs.setString(7,"1966-08-02");   
cs.setString(8,"50000");    
cs.setString(9,"13767654743");
cs.setString(10,"北京市");
int num=cs.executeUpdate();       
while(rs.next())    {
%>                                 
您的第一个字段内容为:<%=rs.getString(1)%><br>
您的第二个字段内容为:<%=rs.getString(2)%><br>
您的第三个字段内容为:<%=rs.getString(3)%><br>
您的第四个字段内容为:<%=rs.getString(4)%><br>
您的第五个字段内容为:<%=rs.getString(5)%><br>
您的第六个字段内容为:<%=rs.getString(6)%><br>
您的第七个字段内容为:<%=rs.getString(7)%><br>
您的第八个字段内容为:<%=rs.getString(8)%><br>
您的第九个字段内容为:<%=rs.getString(9)%><br>
您的第十个字段内容为:<%=rs.getString(10)%>
<p>             
<%}%>                
<%out.print("数据库操作成功,恭喜你");%>                  
<%rs.close();   
stmt.close();                                
conn.close();                  
%> 错误日志如下:
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 JSP: An error occurred at line: 17 in the jsp file: /MyChun.jsp
The method prepareCall(String) in the type Connection is not applicable for the arguments ()
14: String sql="select * from employee";                 
15: ResultSet    rs=stmt.executeQuery(sql); 
16: 
17: CallableStatement cs=Connection.prepareCall();
18: CallableStatement cs=Connection.prepareCall("{call p_insert(?,?,?,?,?,?,?,?,?,?)}");
19: cs.setString(1,"E0021");
20: cs.setString(2,"吴华");
An error occurred at line: 18 in the jsp file: /MyChun.jsp
Duplicate local variable cs
15: ResultSet    rs=stmt.executeQuery(sql); 
16: 
17: CallableStatement cs=Connection.prepareCall();
18: CallableStatement cs=Connection.prepareCall("{call p_insert(?,?,?,?,?,?,?,?,?,?)}");
19: cs.setString(1,"E0021");
20: cs.setString(2,"吴华");
21: cs.setString(3,"男");
An error occurred at line: 18 in the jsp file: /MyChun.jsp
Cannot make a static reference to the non-static method prepareCall(String) from the type Connection
15: ResultSet    rs=stmt.executeQuery(sql); 
16: 
17: CallableStatement cs=Connection.prepareCall();
18: CallableStatement cs=Connection.prepareCall("{call p_insert(?,?,?,?,?,?,?,?,?,?)}");
19: cs.setString(1,"E0021");
20: cs.setString(2,"吴华");
21: cs.setString(3,"男");
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
--------------------------------------------------------------------------------Apache Tomcat/6.0.10