0
我有檢索數據庫項目的代碼,並在使用J2ME的移動應用程序中顯示該項目。我也爲此使用JSP,以便我的移動應用程序可以從中獲取信息。Java /數據庫查詢:檢索多個項目
我想知道如何檢索多個項目?
的JavaBean:
public String doQuery() throws ClassNotFoundException, SQLException {
//register driver
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
//establish connection
Conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/a1electric?user=root&password=raam030");
//Create a Statement object from the Connection
Statement stmt = Conn.createStatement();
String sql = "SELECT JobID FROM employee WHERE employeeID=" +this.jobID;
ResultSet rs = stmt.executeQuery(sql);
String rt = "";
rs.next();
rt = rs.getString("JobID");
Conn.close();
return rt;
}
JSP頁面:
<jsp:useBean id="bean0" scope="session" class="data.queryBean"/>
<jsp:setProperty name="bean0" property="jobID" param="jobID"/>
<%= bean0.doQuery() %>
我想檢索所有作業ID該員工ID,並顯示它。
謝謝你的。這是我的大學項目,所以我並不擔心在這個時候的安全性的一部分。 –