日期:2014-05-18  浏览次数:20650 次

struts2用什么方法连接数据库呀?,我只知道struts1的连接方法请高手帮忙。
struts2用什么方法连接数据库呀?,我只知道struts1的连接方法,

请高手帮忙,说说struts2 如何用JDBC连接数据库的

以下是Struts1的使用方法,在struts2中该用什么方法呢?
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Collection<get_line> ret=new ArrayList<get_line>();
String sql_1="select line_name,price_net,bh from line ";
Conn proxool = new Conn();
try{
ResultSet rs_1 = proxool.resultSet(sql_1);

while(rs_1.next()) {
get_line get_line=new get_line();
  …… ……
  ……
  ……
以上是Struts1的使用方法,在struts2中该用什么方法呢?


------解决方案--------------------
连接数据库跟用什么1还是2,没有关系,你的那个错误提示,不是因为数据库操作那段出错造成的原因。你一行行的标上打印几号,先弄清楚是哪一步出错了
------解决方案--------------------
连接数据库跟用structs的版本没多大关系,
你可以用tomcat的连接池,struts本身的datarsource也行,或者c3p0等

没有找到ActionForward,ActionForm,是不是没有引入struts.jar
------解决方案--------------------
一般的jdbc方式连接数据库在struts1和struts2中用法是一样的
------解决方案--------------------
探讨
那就奇怪了它说找不到这两个东东 ActionForward ,ActionForm