全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 经管百科 爱问频道
935 0
2010-11-21
class SerchChengji extends Panel
implements ActionListener
{  
   Box baseBox ,boxV1,boxV2;
   TextField xh,kc,cj;
   Label l1,l2,l3,l4;
   Button button;
   SerchChengji(  )

   {  
   setBackground(Color.GRAY);
   xh=new TextField(12);
   kc=new TextField(12);
   cj=new TextField(12);
   cj.setVisible(false);
   button=new Button("查询");
   button.addActionListener(this);
   boxV1=Box.createVerticalBox();
   l1=new Label("输入学号");
   boxV1.add(l1);
   boxV1.add(Box.createVerticalStrut(8));
   l2=new Label("输入课程");
   boxV1.add(l2);
   boxV1.add(Box.createVerticalStrut(8));
   l3=new Label("查询成绩是:");
   l3.setVisible(false);
   boxV1.add(l3);
   boxV1.add(Box.createVerticalStrut(8));
   l4=new Label("单击查询");
   boxV1.add(l4);
   boxV2=Box.createVerticalBox();
   boxV2.add(xh);
   boxV2.add(Box.createVerticalStrut(8));
   boxV2.add(kc);
   boxV2.add(Box.createVerticalStrut(8));
   boxV2.add(cj);
   boxV2.add(Box.createVerticalStrut(8));
   boxV2.add(button);
   baseBox=Box.createHorizontalBox();
   baseBox.add(boxV1);
   baseBox.add(Box.createHorizontalStrut(10));
   baseBox.add(boxV2);
   add(baseBox);
   }
   public void actionPerformed(ActionEvent e)
   {   String x;

   String xh2=xh.getText();
       String kc2=kc.getText();
      if(xh2!=null&&kc2!=null)
{ x="select * from  成绩1 where 学号='"+xh2+"'and 课程='"+kc2+"'";
   Connection con;
   Statement sql;
   ResultSet rs;
   try{
   Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  }
  catch(ClassNotFoundException e1){System.out.println(e1);}
  try{

  con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=信管 ","sa","");

  sql=con.createStatement();

  rs=sql.executeQuery(x);

  rs.next();

  int cj2=rs.getInt(3);

  cj.setText(""+cj2);

  validate();

  l1.setVisible(false);

  l2.setVisible(false);

  l4.setVisible(false);

  xh.setVisible(false);

  kc.setVisible(false);

  button.setVisible(false);

  l3.setVisible(true);

  cj.setVisible(true);

  validate();

  con.close();}

  catch(Exception e2){System.out.println(e2);}}

      

         

         }

      

   }
在进行查询过程时,显示java.lang.NumberFormatException: For input string: "绘画"。      查询功能不能实现。不知道哪里出了问题。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群