如何用三大框架从oracle数据库中读取出USERNUMBER属性一样对应的2条数据然后显示在页面上 50
packageaction;//action类importorg.apache.struts2.ServletActionContext;importpo.getserv...
package action;//action类
import org.apache.struts2.ServletActionContext;
import po.getserviceid;
import po.getservicename;
import service.getserviceidService;
import service.getservicenameService;
public class getserviceidandservicenameAction {
private String USERNUMBER;
public String getUSERNUMBER() {
return USERNUMBER;
}
public void setUSERNUMBER(String uSERNUMBER) {
USERNUMBER = uSERNUMBER;
}
getserviceidService gsis;
public getserviceidService getGsis() {
return gsis;
}
public void setGsis(getserviceidService gsis) {
this.gsis = gsis;
}
public String execute(){
getserviceid gsi=gsis.getServiceidByusernumber(USERNUMBER);
ServletActionContext.getRequest().setAttribute("usernumber", gsi.getUSERNUMBER());
ServletActionContext.getRequest().setAttribute("serviceid",gsi.getSERVICEID());
return "go";
}
}
package daoimpl;//
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import po.getservicename;
import dao.getservicenameDao;
public class getservicenameImpl extends HibernateDaoSupport implements getservicenameDao {
public getservicename getServicenameByServiceid(int id) {
final String hql="from getservicename s where s.SERVICEID = ?";
List list = this.getHibernateTemplate().find(hql,new Object[]{id});
if (list.size()!=0) {
return (getservicename) list.get(0);
}
return null;
}
}
我想实现输入电话号码,提交之后显示电话号码所对应的那2个serviceID,我不知道如何获取和遍历!
求大神指点!
下面是其它代码:
jsp页面: 展开
import org.apache.struts2.ServletActionContext;
import po.getserviceid;
import po.getservicename;
import service.getserviceidService;
import service.getservicenameService;
public class getserviceidandservicenameAction {
private String USERNUMBER;
public String getUSERNUMBER() {
return USERNUMBER;
}
public void setUSERNUMBER(String uSERNUMBER) {
USERNUMBER = uSERNUMBER;
}
getserviceidService gsis;
public getserviceidService getGsis() {
return gsis;
}
public void setGsis(getserviceidService gsis) {
this.gsis = gsis;
}
public String execute(){
getserviceid gsi=gsis.getServiceidByusernumber(USERNUMBER);
ServletActionContext.getRequest().setAttribute("usernumber", gsi.getUSERNUMBER());
ServletActionContext.getRequest().setAttribute("serviceid",gsi.getSERVICEID());
return "go";
}
}
package daoimpl;//
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import po.getservicename;
import dao.getservicenameDao;
public class getservicenameImpl extends HibernateDaoSupport implements getservicenameDao {
public getservicename getServicenameByServiceid(int id) {
final String hql="from getservicename s where s.SERVICEID = ?";
List list = this.getHibernateTemplate().find(hql,new Object[]{id});
if (list.size()!=0) {
return (getservicename) list.get(0);
}
return null;
}
}
我想实现输入电话号码,提交之后显示电话号码所对应的那2个serviceID,我不知道如何获取和遍历!
求大神指点!
下面是其它代码:
jsp页面: 展开
展开全部
只要参考“System.Data.OracleClient的”就可以了
连接字符串的例子:拍摄用户ID =用户;数据源=服务器/数据库名称;密码=通过;
其他与sqlserver的是相似的,但这样的改变OracleConnection
的SqlDataAdapter的SqlConnection想改变OracleDataAdapter
的SqlCommand想改变OracleCommand
连接字符串的例子:拍摄用户ID =用户;数据源=服务器/数据库名称;密码=通过;
其他与sqlserver的是相似的,但这样的改变OracleConnection
的SqlDataAdapter的SqlConnection想改变OracleDataAdapter
的SqlCommand想改变OracleCommand
追问
本人接触java不长时间!您说的不是太懂!您能根据我提供的代码帮我修改嘛?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询