Results 1 to 8 of 8
  1. #1
    zuan is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default Compile: symbol not found

    Hi,

    I'm realy new to java, I have a code that i need to compile but when i try it it give me error symbol not found

    My project consist 3 files:

    DbCon.java MemberArticle.java and ArticleDB.java

    I can compile DbCon and MemberArticle but I can't compile ArticleDB.java and here is the ArticleDB code:

    Java Code:
    package MyClass;
    
    import java.sql.*;
    import MyClass.MemberArticle;
    import MyClass.DbCon;
    
    public class ArticleDB {
    	private Connection conn;
    	private PreparedStatement pstmt;
    	private ResultSet rs;
    
    	//1. 생성자 선언 : Connection 인스턴스가 생성되도록 한다.
    	
    	public ArticleDB() throws SQLException {
    		conn = DbCon.getConnection();
    
    	}
    
    	//2. DB에 레코드 갱신을 위한 updateRecord() 메소드 선언
    	//   @param : MemberArticle
    	//   @return : void
    	public void updateRecord(MemberArticle article) throws SQLException {
    		String sql = "UPDATE kagebu SET day=?, month=?, year=?, trans=?, info=?, amount=?, id=? WHERE id=?";
    		pstmt = conn.prepareStatement(sql);
    		pstmt.setString(1, article.getDay());
    		pstmt.setString(2, article.getMonth());
    		pstmt.setString(3, article.getYear());
    		pstmt.setString(4, article.getTrans());
    		pstmt.setString(5, article.getInfo());
    		pstmt.setString(6, article.getAmount());
    		pstmt.setString(7, article.getId());
    
    		pstmt.executeUpdate();
    
    	}
    
    
    
    	//3. 지정된 id에 해당하는 DB에 저장된 레코드를 반환
    	//   @param : String
    	//	 @return : MemberArticle
    
    	public MemberArticle getRecord(String id) 
    		throws SQLException {
    		String sql = "SELECT day, month, year, trans, info, amount,id FROM kagebu WHERE id=?";
    		pstmt = conn.prepareStatement(sql);
    		pstmt.setString(1, id);
    
    		rs = pstmt.executeQuery();
    
    		rs.next(); // 반환되는  record는 오직 하나.
    
    		MemberArticle article = new MemberArticle();
    		
    		article.setDay(rs.getString("day"));
    		article.setMonth(rs.getString("month"));
    		article.setYear(rs.getString("year"));
    		article.setTrans(rs.getString("trans"));
    		article.setInfo(rs.getString("info"));
    		article.setAmount(rs.getString("amount"));
    		article.setId(rs.getString("id"));
    
    		return article;
    
    
    
    
    	}
    
    
    
    	//4. open된 모든 연결자 정보를 제거
    	//   @param is'nt 
    	//   @return void
    
    	public void close() throws SQLException{
    		if(rs != null) rs.close();
    		if(pstmt != null) pstmt.close();
    		if(conn != null) conn.close();
    	}
    }
    DbCon.java:

    Java Code:
    package MyClass;
    
    import java.sql.*;
    
    public class DbCon
    {
    	final static String URL = "jdbc:mysql://localhost:3306/housekeeping?useUniCode=true&characterEncoding=euckr";
    	final static String USER = "user";
    	final static String PASSWORD = "pass";
    	static {
    		try	{
    			Class.forName("com.mysql.jdbc.Driver");
    		}catch (ClassNotFoundException e)
    		{
    			System.out.println(e.getMessage());
    		}
    	}
    
    	public static Connection getConnection() throws SQLException {
    		return DriverManager.getConnection(URL, USER, PASSWORD);
    	}
    }
    MemberArticle.java:
    Java Code:
    package MyClass;
    
    public class MemberArticle
    {
    	private String id;
    	private String day;
    	private String month;
    	private String year;
    	private String trans;
    	private String info;
    	private String amount;
    
    	//선언된 멤버들에 대한 getter와 setter 메소드를 선언해 준다.
    	public void setDay(String day) {
    		this.day = day;
    	}
    
    	public void setMonth(String month) {
    		this.month = month;
    	}
    
    	public void setYear(String year) {
    		this.year = year;
    	}
    
    	public void setTrans(String trans) {
    		this.trans = trans;
    	}
    
    	public void setInfo(String info) {
    		this.info = info;
    	}
    
    	public void setAmount(String amount) {
    		this.amount = amount;
    	}
    
    	public void setId(String id) {
    		this.id = id;
    	}
    
    	public String getDay(){
    		return day;
    	}
    
    	public String getMonth(){
    		return month;
    	}
    
    	public String getYear(){
    		return year;
    	}
    
    	public String getTrans(){
    		return trans;
    	}
    
    	public String getInfo(){
    		return info;
    	}
    
    	public String getAmount(){
    		return amount;
    	}
    
    	public String getId(){
    		return id;
    	}
    }
    weird thing is my friend said he can compile it with no error but when i get the compiled files and put it on my server it will give me error no symbol found error on the webbrower so i dont know which part i'm wrong here maybe my computer configuration? if yes what should i change? I already put the proper classpath that needed but still no luck.

    Compile error:
    Java Code:
    ---------- Java Compile ----------
    X:\MyClass\ArticleDB.java:4: cannot resolve symbol
    symbol  : class MemberArticle 
    location: package MyClass
    import MyClass.MemberArticle;
                   ^
    X:\MyClass\ArticleDB.java:5: cannot resolve symbol
    symbol  : class DbCon 
    location: package MyClass
    import MyClass.DbCon;
                   ^
    X:\MyClass\ArticleDB.java:22: cannot resolve symbol
    symbol  : class MemberArticle 
    location: class MyClass.ArticleDB
    	public void updateRecord(MemberArticle article) throws SQLException {
                                     ^
    X:\MyClass\ArticleDB.java:43: cannot resolve symbol
    symbol  : class MemberArticle 
    location: class MyClass.ArticleDB
    	public MemberArticle getRecord(String id) 
                   ^
    X:\MyClass\ArticleDB.java:15: cannot resolve symbol
    symbol  : variable DbCon 
    location: class MyClass.ArticleDB
    		conn = DbCon.getConnection();
                           ^
    X:\MyClass\ArticleDB.java:53: cannot resolve symbol
    symbol  : class MemberArticle 
    location: class MyClass.ArticleDB
    		MemberArticle article = new MemberArticle();
                    ^
    X:\MyClass\ArticleDB.java:53: cannot resolve symbol
    symbol  : class MemberArticle 
    location: class MyClass.ArticleDB
    		MemberArticle article = new MemberArticle();
                                                ^
    7 errors
    
    Output completed (2 sec consumed)
    Thanks
    Last edited by zuan; 06-22-2008 at 05:17 PM.

  2. #2
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default Hi

    Its very simple error.
    You dont have to explicitly import the classes of same package.
    So when u r trying to import MyClass.MemberArticle, its throwing the error
    and where ever u r using that class its throwing the same error.

    Remove that import stmt.
    To finish sooner, take your own time....
    Nivedithaaaa

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Better to refer some documents on these basis. Sun's official website have a grate/simple explanation on those things.

  4. #4
    zuan is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by Niveditha View Post
    Its very simple error.
    You dont have to explicitly import the classes of same package.
    So when u r trying to import MyClass.MemberArticle, its throwing the error
    and where ever u r using that class its throwing the same error.

    Remove that import stmt.
    Already done that it only remove the 1st 2 error the other 5 still remain

    Quote Originally Posted by Eranga View Post
    Better to refer some documents on these basis. Sun's official website have a grate/simple explanation on those things.
    no luck have being digging around but no luck at all, when I try to use -verbose i can see that javac dont even search the -classpath that I manually added :( I'm stuck and dont know what the cause ... :mad:

  5. #5
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Hello Zuan,
    to remove all the errors u need to remove
    import MyClass.DbCon;
    with
    import MyClass.MemberArticle;
    as u can see clearly both r in the same package as i said u dont have to import them.
    I think that was the problem.
    To finish sooner, take your own time....
    Nivedithaaaa

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Why don't you try all those thing on command prompt and the Notepad. I think it's much better to use in the beginning. Even on the command prompt you can easily find those errors. Not much explanation you get there, but it's worth at all.

  7. #7
    zuan is offline Member
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Why don't you try all those thing on command prompt and the Notepad. I think it's much better to use in the beginning. Even on the command prompt you can easily find those errors. Not much explanation you get there, but it's worth at all.
    I'm using command prompt + textpad

    Quote Originally Posted by Niveditha
    Hello Zuan,
    to remove all the errors u need to remove
    import MyClass.DbCon;
    with
    import MyClass.MemberArticle;
    as u can see clearly both r in the same package as i said u dont have to import them.
    I think that was the problem.
    Nope still the same :p

    btw i manage to find out why it wont compile, the directory for all the files must be in a directory which have exact name as the package for this to work and i didnt know that :eek: :p

    thank for the input :cool:

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by zuan View Post
    btw i manage to find out why it wont compile, the directory for all the files must be in a directory which have exact name as the package for this to work and i didnt know that :eek: :p
    This is optional. I mean, for a example if your class MemberArticle in a folder named MyClass then you have to import them as a package.

    Java Code:
    import MyClass.MemberArticle;
    if you want to use all classes on that folder you import all of them as follows.

    Java Code:
    import MyClass.*;
    If all classes in the same folder(in Java also called as a package) no need to import any class in another class.

Similar Threads

  1. GeoPoint Not found
    By nvidia in forum NetBeans
    Replies: 2
    Last Post: 05-28-2008, 09:31 PM
  2. symbol not found error
    By rmartyce in forum New To Java
    Replies: 1
    Last Post: 05-23-2008, 05:58 AM
  3. Replies: 3
    Last Post: 05-01-2008, 08:30 AM
  4. could not be found in the registry
    By alam99 in forum Eclipse
    Replies: 0
    Last Post: 01-08-2008, 08:21 AM
  5. 404 Not Found
    By mary in forum Java Servlet
    Replies: 5
    Last Post: 11-07-2007, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •