Here is the code... Problem is that it shows a message retCode is not initialized if i written last line in try block it shows return error i dun understand wat to do now plz friends help me

private boolean spellCheck(String spell)
    {
        Connection Conn;
        Statement Stat;
        ResultSet Rs;
        String match;
        Boolean retCode;
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbc");
            Conn = DriverManager.getConnection("jdbc:odbc:Vocabulary");
            Stat = Conn.createStatement();
            String que = "Select * From Scrabble WHERE id = "+ spell;
            Rs = Stat.executeQuery(que);
            match = Rs.getString(1);
                        if(match != null)
                retCode=true;
        }
        catch(SQLException e)
        {}
        catch(ClassNotFoundException cnfe)
        {}
        return retCode;
    }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Java is checking that retCode will always have a value assigned, no matter which path through your code is executed.
If, for example, the getConnection fails, it will go straight to the catch, and retCode will never have a vaue assigned to it.
You can either intialise it when you declare it
Boolean retCode = false;
or (and I prefer this), set it to false in the catch blocks.

i tried the second option bt still it gives the same error... i wanna ask another thing i have created an applet which has one main file and 7 other class files now i want to connect it to database the above code is in class file on compiling it gives access control exception... i have edit the policy file with this code

grant
{
    permission java.lang.RuntimePermission
        "accessClassInPackage.sun.jdbc.odbc";
};

grant 
{
        permission java.lang.RuntimePermission
        "accessClassInPackage.sun.jdbc.odbc";
        permission java.util.PropertyPermission
        "file.encoding", "read";
};

bt still its not working and gives same access control exception

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Did you put it in both catch blocks? Anyway, the first option will work.
Sorry, I don't have experience relevant to your second problem, but you should post that as a new Thread with a suitable title so that the right people can help you.

This article has been dead for over six months. Start a new discussion instead.