How to get javabean property

Category: Web Develop
 
jintianjun
2013-02-27 07:40:29

Sponsored Links
I have a bean as follows:
package quanxian_db;
import java.sql. *;

Public class ConnOracle {
; String sDBDiver = "sun.jdbc.odbc.JdbcOdbcDriver";
Connection connect = null;
/ / Statement stmt;
ResultSet rs = null;
int result = 0;

public ConnOracle () {
try {
Class.forName (sDBDiver);
}
catch (java.lang.ClassNotFoundException e) {
; System.err.println (e.getMessage ());
}
}

public ResultSet executeQuery (String sql) {
try {
connect = DriverManager.getConnection ("jdbc: odbc: XinHaoFenxi", " system "," pass ");
Statement stmt = connect.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = stmt. executeQuery (sql);
}

catch (SQLException ex) {
; System.err.println (ex.getMessage ());
}
return rs;
}

public int executeUpdate (String sql) {

try {
connect = DriverManager.getConnection ("jdbc: odbc: XinHaoFenxi", "system", "pass");
Statement stmt = connect.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
result = stmt.executeUpdate (sql);
; connect.commit () ;/ / new additions statement
}

catch (SQLException ex) {
/ / connect.rollback () ;/ / new additions statement
System.err.println (ex . getMessage ());
}
return result;
}

}

to call the jsp code is as follows:
<% @ page contentType = "text / html; charset = gb2312"%>
<% @ page language = "java" import = "java.sql. *"%>
<jsp: useBean id = "connDb" scope = "page" class = "quanxian_db.ConnOracle" />
......

I can
<%
connDb.result ;/ / get the bean attributes?
%>

Sponsored Links

yjhlb
2013-02-27 07:44:05
If you want to get the attribute result, then you must define the result in the class is defined as publicly owned
j87793926
2013-02-27 07:46:53
<jsp: useBean ; id = ".." class = ".." property = "attribute name">
you can get the value of the property ...
You can make a loop ...
ss56526716
2013-02-27 08:00:44
jiang_zhongping (sword snow):
how to get, that is, how to write?
jiangaijie
2013-02-27 08:14:32
I think you should call before you can build your so-called attribute ah.
such as: <% ResultSet result = connDb.executeUpdate ("select * from ......");%>
so that it can effect it.
q778395769
2013-02-27 08:22:34
where there is so used in the page to obtain RESULTSET, wording too amateur, I faint ~
donlen111
2013-02-27 08:41:21
babap1234 (I was stupid) is right.
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.