LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 563|回复: 1

问一个jsp问题

[复制链接]
发表于 2004-4-25 16:20:12 | 显示全部楼层 |阅读模式
我写了一个jsp+bean,但是有好多问题,先看看我的代码吧
[php]
package testdata;
import java.sql.*;
import javax.sql.*;
import java.io.*;
public class test4 implements Serializable
{
       String userName="";
       String userPassword="";
       public void setUserName(String userName)
       {
              this.userName=userName;
       }
       public void setUserPassword(String userPassword)
       {
              this.userPassword=userPassword;
       }
       public String getUserName()
       {
              return userName;
       }
       public String getUserPassword()
       {
              return userPassword;
       }

}
[/php]

这是另一个
[php]
package testdata;
import java.sql.*;
import javax.sql.*;
import java.io.*;
import java.util.*;
public class test7
{
       String name="";
       String password="";
       Connection con;
       PreparedStatement pstmt;
      
       test7()
       {
            try
            {
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con=DriverManager.getConnection("jdbcdbc:TIS","administrator","");
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
       }
       public Collection listInfo()
       {
              test4 temp=new test4();
              name=temp.getUserName();
              password=temp.getUserPassword();
              Collection ret=new ArrayList();
              try
              {
                        
                  pstmt=con.prepareStatement("SELECT * FROM Purview1 WHERE PName=? AND PPassword=?  ");
                  pstmt.setString(1,name);
                  pstmt.setString(2,password);
                  ResultSet res=pstmt.executeQuery();
                  
                  while(res.next())
                  {
                       temp.setUserName(res.getString("Name"));
                       temp.setUserPassword(res.getString("Password"));
                       ret.add(temp);
                  }
              }
              catch(Exception e)
              {
                e.printStackTrace();
              }
              return ret;
       }
}
[/php]

这是部分jsp页的验证
[php]
<%
      
      Collection tests=test.listInfo();
      Iterator it=tests.iterator();
      while(it.hasNext())
      {
             test4 temp=(test4)it.next();
             out.println(temp.getUserName()+"-"+temp.getUserPassword());
            
      }
%>
[/php]
但是出现以下信息
[php]
500 Servlet Exception
Note: sun.tools.javac.Main has been deprecated.
/test1/testBank1.jsp:19: Class _test1.test4 not found.
             test4 temp=(test4)it.next();
             ^
/test1/testBank1.jsp:19: Class _test1.test4 not found.
             test4 temp=(test4)it.next();
                         ^
2 errors, 1 warning



--------------------------------------------------------------------------------
Resin 2.1.7 (built Fri Feb 14 12:48:13 PST 2003)
[/php]
我放置class文件路径是正确的,请各位高手指点
发表于 2004-4-25 18:26:41 | 显示全部楼层
下次发贴时请注意保持代码缩进,不然太难看了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表