这是我查询的那个方法,执行查询。可是不行,是不是我下面的的查询语句有问题:
String querySql="SELECT student.student_ID,student_name,course_name,result" +
" FROM student,course,xuanxiu" +
"WHERE student.student_ID=xuanxiu.student_ID " +
"ANDxuanxiu.course_ID=course.course_ID";
public void search()
{
//创建查询条件面板
final JTextField txtNumber=new JTextField();
txtNumber.addActionListener(tfl);
JTextField txtName=new JTextField();
txtName.addActionListener(tfl);
JPanel sp=new JPanel();
sp.setLayout(new GridBagLayout());
LayoutUtil.add(sp,GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER,100,0,0,0,1,1,new JLabel("学生编号"));
LayoutUtil.add(sp,GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER,100,0,0,1,1,1,txtNumber);
LayoutUtil.add(sp,GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER,100,0,0,2,1,1,new JLabel("学生姓名"));
LayoutUtil.add(sp,GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER,100,0,0,3,1,1,txtName);
//txtName获得输入焦点
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
txtNumber.requestFocus();
}
});
//创建查询对话框
String[] options = { "确定", "取消"};
int result = JOptionPane.showOptionDialog(
father, // 父组件
sp, // 查询条件面板
"查询条件", // 对话框标题
JOptionPane.DEFAULT_OPTION, // 选项类型
JOptionPane.QUESTION_MESSAGE, // 消息类型
null, //图标
options, // 按钮
options[0] // 缺省按钮
);
if(result==JOptionPane.OK_OPTION)
{ //用户按下确定按钮
String querySql="SELECT student.student_ID,student_name,course_name,result" +
" FROM student,course,xuanxiu" +
"WHERE student.student_ID=xuanxiu.student_ID " +
"ANDxuanxiu.course_ID=course.course_ID";
SqlUtil.readDBToTable(con,querySql,model,dataType);
}
}