Автоматически заполнять значение inputText
Я хочу получить ResultSet
что я извлек из базы данных в inputText в файле xhtml. Ниже показан код, который я пробовал до сих пор.
Profile.java
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import com.mpts.srv.DBConnection;
public class Profile {
public void info(){
String name = null;
String mykad = null;
String contact = null;
Date dob = null;
String gender = null;
String email = null;
DBConnection dbconn = new DBConnection("com.mysql.jdbc.Driver", "jdbc:mysql://localhost", "root",
"root");
dbconn.query("SELECT * FROM Patient WHERE patient_uid = SessionUtils.getUid()");
ResultSet rs = dbconn.getResultSet();
try {
while (rs.next()) {
name = rs.getString("name");
mykad = rs.getString("mykad");
contact = rs.getString("contact");
dob = rs.getDate("dob");
gender = rs.getString("gender");
email = rs.getString("email");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dbconn.close();
}
}
profile.xhtml
<h:outputLabel value="Name:"></h:outputLabel>
<b:inputText span="8" value="#{profile.getString(Name)}"></b:inputText>
Как мне заселить name
в inputText?