nhờ giúp sửa lỗi cannot find symbol ?

Discussion in 'Xây dựng ứng dụng chạy console, applet' started by lknam193, 17/3/12.

  1. lknam193 New Member

    mình bị lỗi ở đoạn SinhVien s=new SinhVien(MaSV); trong hàm SinhVien login, tại sao lại bị lỗi không tìm thấy kiểu và phải sửa làm sao?

    PHP:
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.sql.*;
    import java.text.*;

    //-----------------------------------------------------
        
    public class SinhVien implements Database 
        
    {
            private 
    Double MaSV;
            private 
    String HoTen;  
            private 
    String MatKhau;
            private 
    String Status;
            private 
    String LopSH;
            private 
    String MaHK;
            public 
    SinhVien()
            {
                try{
                    Class.
    forName(driver);    
                }
                catch ( 
    Exception e){
                    
    System.out.println(e);
                }
            }
            public 
    SinhVien(Double msvString htString mkString sttString lsh)
            {
                
    this.MaSV=msv;
                
    this.HoTen=ht;
                
    this.MatKhau=mk;
                
    this.Status=stt;
                
    this.LopSH=lsh;
            }
            public 
    void SinhVien(String MaSVthrows Exception
                
    {
                    
    Connection con =null;
                    try{
                        
                        Class.
    forName(driver);
                        
    con DriverManager.getConnection(sourceURL);
                        
    Statement stmt con.createStatement();
                        
    ResultSet rs stmt.executeQuery("Select MaSV, HoTen, MatKhau, Status, LopSH from SinhVien where MaSV="+MaSV+"");
                        if(
    rs.next()){
                            
    this.MaSV=rs.getDouble("MaSV");
                            
    this.HoTen=rs.getString("HoTen");
                            
    this.MatKhau=rs.getString("MatKhau");
                            
    this.Status=rs.getString("Status");
                            
    this.LopSH=rs.getString("LopSH");
                        }    
                    }catch(
    Exception e){
                        
    System.out.println(e);
                    }
                    
    finally
                    
    {
                        
    con.close();
                    }
            }
    //--------------------------------------------------------
            
    public static SinhVien Login (Double MaSVString MatKhau){
            try{
                
    SinhVien s=new SinhVien(MaSV);/*cannot find symbol?*/
                
    if (s.MatKhau.equals(MatKhau))
                    return 
    s
                else return 
    null;
                }
                catch (
    Exception e){return null;}
            }
    //--------------------------------------------------------
            
    public Double getMaSV()
            {
                return 
    MaSV;
            }
            public 
    String getHoTen()
            {
                return 
    HoTen;
            }
            public 
    String getMatKhau()
            {
                return 
    MatKhau;
            }
            public 
    String getStatus()
            {
                return 
    Status;
            }
            public 
    String getLopSH()
            {
                return 
    LopSH;
            }
    //-----------------------------------------------------        
            
    public Vector TKB(int HocKythrows Exception{
                
    Connection con =null;
                
    Vector v =new Vector(10,10);
                
    Vector head = new Vector();
                
    Vector rows = new Vector();
                try{
                    
                    Class.
    forName(driver);
                    
    con DriverManager.getConnection(sourceURL);                
                    
    PreparedStatement stmt con.prepareStatement("SELECT LopHP.MaLHP, SinhVien.MaSV, HocPhan.TenHP, LopHP.Thu, LopHP.TuTiet, LopHP.DenTiet, LopHP.Phong, LopHP.HocKy FROM SinhVien INNER JOIN ((HocPhan INNER JOIN LopHP ON HocPhan.MaHP = LopHP.MaHP) INNER JOIN LopHPSV ON (LopHP.MaLHP = LopHPSV.MaLHP) AND (HocPhan.MaHP = LopHPSV.MaHP)) ON SinhVien.MaSV = LopHPSV.MaSV WHERE SinhVien.MaSV=? AND LopHP.HocKy=?");
                    
    stmt.setDouble(1,MaSV);
                    
    stmt.setInt(2,HocKy);
                    
    ResultSet rs stmt.executeQuery();
                    
    ResultSetMetaData rsmd rs.getMetaData();
                    for(
    int i=1;i<=rsmd.getColumnCount();i++) 
                        
    head.addElement(rsmd.getColumnName(i));
                    
    v.add(head);                
                    while(
    rs.next()){
                        for (
    int i=1;<=rsmd.getColumnCount();i++)
                            
    rows.addElement(rs.getObject(i)); 
                    } 
                    
                    
    v.add(rows);
                }catch(
    Exception e){
                    
    System.out.println(e);
                }
                
    finally
                
    {
                    
    con.close();
                }
                return 
    v;
            }
    //----------------------------------------------------------
            
    public String toString()
            {
                return (
    "MaSV :"MaSV +"\nHoTen :" HoTen "\nMatKhau :" MatKhau "\nStatus :" Status "\nLopSH :" LopSH "\n");

            }
        public static 
    void main(String[] argsthrows Exception
        
    {
            
    SinhVien SV = new SinhVien();
            
    SV.SinhVien("112250532139");
            
    System.out.println(SV);
            
    Vector kq =SV.TKB(111);
                
    Vector head = (Vector)kq.get(0);
                
    Vector rows = (Vector)kq.get(1);
                for(
    int i=0;i<rows.size();i++)
                {    
                    
    System.out.print(rows.get(i));
                    
    System.out.print("\n");
                }
        }
    }
  2. Dạ Nguyệt New Member

    Ðề: nhờ giúp sửa lỗi cannot find symbol ?

    Tôi không thấy constructor nào có dạng SinhVien(Double) cả!
  3. lknam193 New Member

    Ðề: nhờ giúp sửa lỗi cannot find symbol ?

    vậy bây giờ mình phải viết một hàm SinhVien kiểu Double nữa phải không ?.. các bạn có thể hướng dẫn mình viết như thế nào không ?
  4. dungdn19 New Member

    Ðề: nhờ giúp sửa lỗi cannot find symbol ?

    sửa cái
    private Double MaSV;
    thành kiểu String đi, đã có 1 hàm dựng 1 đối số sẵn là kiểu String rồi làm thêm nữa làm gì, mà MaSV mà làm kiểu Double thì:-ss


    public void SinhVien(String MaSV) throws Exception
    bỏ cái void đó đi, hàm dựng 1 đối số làm gì có khai báo void

Chia sẻ trang này



Ve may bay di Ha Noi | Ve may bay di Vinh | Ve may bay di Hue | Ve may bay di Da Nang | Ve may bay di Nha Trang | Ve may bay di Da Lat | Ve may bay di Phu Quoc | Ve may bay di Sai Gon | Ve may bay di TPHCM | Ve may bay di Buon Me Thuot | Ve may bay di Hai Phong | Ve may bay di Dong Hoi | Ve may bay Vietjet Air | Phong ve may bay Vietjet Air | Ve may bay Vietnam Airlines | Phong ve may bay Vietnam Airlines | Ve may bay Vietnam Airlines | Ve may bay gia re | Ve may bay | Mua ve may bay | Jetstar | Vietnam Airlines | Air Asia | Tiger Airways | Ve may bay di My | Vietjet Air | Ve may bay di Ha Noi | Ve may bay di Da Nang | Ve may bay di Hai Phong | Ve may bay di Vinh