动态表格生成(oracle库直读数据)

public  String commandButton_action()
{
    
// Add event code here...
    
    ResultSet rs
=null;
    
try{
Class.forName(
"oracle.jdbc.OracleDriver");
String url
="jdbc:oracle:thin:@<host>:<port>:<database>";
Connection connection 
= DriverManager.getConnection(url,
                     
"OE""<password>");

Statement stmt
=connection.createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

rs
=stmt.executeQuery((String)inputText1.getValue());


dataTable1.setBorder(
5);
dataTable1.setCellpadding(
"1"); 
dataTable1.setVar(
"catalog");


HtmlOutputText headerComponent 
= new HtmlOutputText();
    headerComponent.setValue(
"CatalogId");
    column1.setHeader(headerComponent);


headerComponent 
= new HtmlOutputText();
    headerComponent.setValue(
"Journal");
    column2.setHeader(headerComponent);

headerComponent 
= new HtmlOutputText();
    headerComponent.setValue(
"Publisher");
    column3.setHeader(headerComponent);

headerComponent 
= new HtmlOutputText();
    headerComponent.setValue(
"Edition");
    column4.setHeader(headerComponent);

headerComponent 
= new HtmlOutputText();
    headerComponent.setValue(
"Title");
    column5.setHeader(headerComponent);

headerComponent 
= new HtmlOutputText();
    headerComponent.setValue(
"Author");
    column6.setHeader(headerComponent);

HtmlOutputText column1Text
=new HtmlOutputText();
ValueBinding vb 
= 
FacesContext.getCurrentInstance().getApplication().createValueBinding(
"#{catalog.id}");
column1Text.setValueBinding(
"value", vb);
column1.getChildren().add(column1Text);

HtmlOutputText column2Text
=new HtmlOutputText();
vb 
= 
FacesContext.getCurrentInstance().getApplication().createValueBinding(
"#{catalog.journal}");
column2Text.setValueBinding(
"value", vb);
column2.getChildren().add(column2Text);

HtmlOutputText column3Text
=new HtmlOutputText();
vb 
= 
FacesContext.getCurrentInstance().getApplication().createValueBinding(
"#{catalog.publisher}");
column3Text.setValueBinding(
"value", vb);
column3.getChildren().add(column3Text);


HtmlOutputText column4Text
=new HtmlOutputText();
vb 
= 
FacesContext.getCurrentInstance().getApplication().createValueBinding(
"#{catalog.edition}");
column4Text.setValueBinding(
"value", vb);
column4.getChildren().add(column4Text);

HtmlOutputText column5Text
=new HtmlOutputText();
vb 
= FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.title}");
column5Text.setValueBinding(
"value", vb);
column5.getChildren().add(column5Text);


HtmlOutputText column6Text
=new HtmlOutputText();
vb 
= FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.author}");
column6Text.setValueBinding(
"value", vb);
column6.getChildren().add(column6Text);

ResultSetDataModel dataModel
=new ResultSetDataModel();
dataModel.setWrappedData(rs);
dataTable1.setValue(dataModel);

}

catch(SQLException e){}
catch(ClassNotFoundException e){}
finally{ rs.close();
          stmt.close();
          connection.close();
       }


    
return null;
}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值