Results 1 to 2 of 2

Thread: Newbie in JAVA. Help plz..

  1. #1

    Thread Starter
    Fanatic Member louvelle's Avatar
    Join Date
    Jun 2008
    Posts
    513

    Newbie in JAVA. Help plz..

    Hi guyz!

    I'm a newbie in JAVA and I have a problem.

    Code:
    		record2 rec = new record2();
    		rec.connect();
    		rec.getClass();
    Error here>>>>>		stmt = rec.con.createStatement();
    		String sqlFind = "SELECT * FROM tblSample WHERE ID = 1";
    This one too>>>		ResultSet rst = stmt.executeQuery(sqlFind);
    I have 2 classes and I'm trying to call con in my 2nd class. But I get an error like this:

    Code:
    Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    	The local variable rst may not have been initialized
    	Unhandled exception type SQLException
    
    	at Record.main(Record.java:44)
    I have no problem in creating a connection if i use one class. But it kinda sucks having a lot of code in the class so I'm trying to make a new one.

    Can you plz help me...?
    Thanks!.. ^_^

    Manny Pacquiao once posted in his twitter:
    It doesn't matter if the grammar is wrong, what matter is that you get the message

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Newbie in JAVA. Help plz..

    I think this exception is caused by another part of your code. If you'd post more code perhaps I could help
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

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



Click Here to Expand Forum to Full Width