java成绩查询问题 为什么查询和插入不能实现

来源:百度知道 编辑:UC知道 时间:2024/06/20 16:39:16
class cjcx extends Frame implements ActionListener
{ Button first=new Button("第一条"), last=new Button("最后一条"), previous=new Button("上一条"),
next=new Button("下一条"),cx=new Button("查询"),change=new Button("更改年龄"),cr=new Button("插入"),del=new Button("删除");
。。。。。。
Connection con=null; Statement stmt=null,sql=null; ResultSet rs=null;
cjcx()
{setVisible(true);
。。。。
p3.add(cx);p3.add(new Label("请输入姓名"));p3.add(name1);
first.addActionListener(this);
。。。。
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException cnfe){System.out.println(cnfe);}
try{
con=DriverManager.getConnection("jdbc:odbc:sun","","");
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY)

应该是sql的异常,你那几个捕获异常后都没输出,所以不报异常
输出异常用 异常.printStackTrace(),不用System.out
你在catch块中用sqle.printStackTrace()把异常输出出来就能看到了

单步调试,一步一步看,看看哪里与预期的结果不一样。

ps:编程就是要这样反复调试。