Java 满足条件时在表中显示值
当Java 满足条件时在表中显示值,java,swing,Java,Swing,当账户类型为1时,我需要在我的jTable中显示Admin的值,如果是2则显示出纳。请帮帮我。。以下是我的片段: private void Update_table() { try{ String sql = "SELECT idno as 'User ID', username as 'Username', password as 'Password', account_type as 'Account_Type' from user"; st =
账户类型
为1
时,我需要在我的jTable中显示Admin
的值,如果是2
则显示出纳
。请帮帮我。。以下是我的片段:
private void Update_table() {
try{
String sql = "SELECT idno as 'User ID', username as 'Username', password as 'Password', account_type as 'Account_Type' from user";
st = con.createStatement(rs.TYPE_SCROLL_SENSITIVE,
rs.CONCUR_UPDATABLE);
rs = st.executeQuery(sql);
while(rs.next())
{
if(rs.getInt(4)==1)
{
rs.updateString(4, "1");
}
viewUserTable.setModel(DbUtils.resultSetToTableModel(rs));
viewUserTable.setRowSelectionAllowed(true);
viewUserTable.setSelectionMode(SINGLE_SELECTION);
viewUserTable.setAutoResizeMode(5);
}
此处没有足够的信息来确定您正在尝试做什么或什么不起作用。这属于
TableCellRenderer
的范围,