java - 如何通过选择 jcombobox 值来填充 jtable
问题描述
我是编程新手。我有一个带有表约会的数据库。表字段医生,患者姓名。我想通过从 jcombobox 中选择医生来使用医生和患者姓名填充 jtable。我在下面尝试过,但在表中只带来了列名,没有数据。没有错误。谢谢。
try
{
String comboVal=(String)cbox_doctors.getSelectedItem();
String sql1="select doctor, patient_firstname, patient_surname from
appointments where doctor=?";
pst1=conn.prepareStatement(sql1);
pst1.setString(1, comboVal);
rs1=pst1.executeQuery();
while(rs1.next())
{
table_report.setModel(DbUtils.resultSetToTableModel(rs1));
}
}
catch(Exception e)
{
//JOptionPane.showMessageDialog(null,"error");
System.out.println(e);
} finally {
try{
rs1.close();
pst1.close();
}
catch(Exception e){
}
}
解决方案
推荐阅读
- css - 第一个元素内联块 CSS 选择器
- python - Python 的 splat 运算符……在某一时刻吗?
- google-apps-script - 根据单元格值/复选框添加空白行
- python - 从 BeautifulSoup 行中提取标签文本
- azure-devops - 如何始终将 Azure DevOps 发布任务中的“出错时继续”字段标记为 true?
- jmeter - 如何从 Jmeter 日志查看器获取数据并发送到另一个下一个请求
- c# - 如何通过使用 MVVM 模式单击一个来启用/禁用 wpf 中不同组合框的组合框项目?
- c# - Unity 模糊渲染器不适用于天空盒/透明图像?
- linux - 提取网页中两个已知字符串之间的文本并存储在变量中
- c - 为什么下面的代码容易受到堆溢出攻击