try{
stat.setString(1,TitleText.getText());
stat.setString(2,new String(UserPassword.getPassword()));
pid=stat.executeQuery();
if(pid.next()){
JOptionPane.showMessageDialog(Employee_Login,"登录成功");
}else{
JOptionPane.showMessageDialog(Employee_Login,"登录失败");
}
}catch(SQLException e){
System.out.println("Error");
}
错误异常  请我帮解决下啊  谢谢高手大哥大姐们啦
java.lang.ClassNotFoundException: sun.jdbc,odbc.JdbcOdbcDriver
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at Employee_Management.actionPerformed(Employee_Management.java:95)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)小弟真的不知道是什么原因了明天要交作业  可以找不出原因啊

解决方案 »

  1.   

    catch(SQLException e){ 
    System.out.println("Error"); 

    你又不准备输出详细错误信息,为什么不用Exception e呢?
      

  2.   

    sun.jdbc,odbc.JdbcOdbcDriver  没有引入jdbcdriver
      

  3.   

    数据库驱动包没import到工程里,网上gg一下,很多地方都有驱动包下载的.
      

  4.   

    java.lang.ClassNotFoundException: sun.jdbc,odbc.JdbcOdbcDriver  类没有找到 ,
    工程没有 添加jar包
      

  5.   

    函数入口的定义public static void main(String args[])
    {
    Employee_Management Exam=new Employee_Management();
    try{
    Class.forName("sun.jdbc,odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:MydataSource","sa","66978061");
    stat=con.prepareStatement("select * from Administrators where UseName=? and Pass_word=?");
    }catch(Exception e){
    System.out.println(e);
    }
      

  6.   

    public static void main(String args[]) 

    Employee_Management Exam=new Employee_Management(); 
    try{ 
    Class.forName("sun.jdbc,odbc.JdbcOdbcDriver"); //你写了逗号
    con=DriverManager.getConnection("jdbc:odbc:MydataSource","sa","66978061"); 
    stat=con.prepareStatement("select * from Administrators where UseName=? and Pass_word=?"); 
    }catch(Exception e){ 
    System.out.println(e); 
    }
    sun.jdbc.odbc.JdbcOdbcDriver