0
try {
Statement stmt = conn.createStatement();
String sql = "CREATE OR REPLACE FUNCTION search_admin(p_username IN varchar2) \n"+
"RETURN SYS_REFCURSOR \n" +
"AS \n" +
"my_cursor SYS_REFCURSOR; \n" +
"BEGIN \n" +
"OPEN my_cursor FOR SELECT * FROM login where username=p_username; \n" +
"RETURN my_cursor; \n" +
"END; \n";
stmt.execute(sql);
CallableStatement cstmt = conn.prepareCall("BEGIN " + "? :=search_admin(?); " + "END; ");
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.setString(2, UserText3.getText());
cstmt.execute();
rs = (ResultSet) cstmt.getObject(1);
if(!rs.isBeforeFirst()) {
JOptionPane.showMessageDialog(null, "Invalid Username");
}
else {
DeleteTable.setModel(DbUtils.resultSetToTableModel(rs));
DeleteTable.setEnabled(false);
}
while(rs.next()) {
NameLabel.setText(rs.getString("name"));
UsernameLabel.setText(rs.getString("username"));
PasswordLabel.setText(rs.getString("password"));
}
} catch(Exception e) {
JOptionPane.showMessageDialog(null, e);
}
我想顯示在jlabels
用戶名,姓名,密碼,但它沒有顯示...我在數據庫中名爲search_admin存儲功能。當我執行程序沒有顯示錯誤,但jlabels
不顯示resultset
數據。的JLabel沒有顯示的結果中的JLabel
下面這行可能會耗盡ResultSet:'DbUtils.resultSetToTableModel(rs)',所以你沒有什麼可讀的了。 – Berger
那麼解決方案是什麼? –