Where is that second set of code, what class and package? Is it in the
same package, likely not. Do you have an import statement that refers to
the "dbconnect" class? If not, fully qualify it when you reference it.
Other notes:
1. I realize your 1st language is not English; nevertheless
professionalism (and respect for any language that you use) demands that
I point out a few typos - StudentRecord -> StudentRecord, conect() ->
connect().
2. CamelCase your class names, e.g. DbConnect.
3. Your 'url' + 'db' concatenation, *everything* joined is potentially
the JDBC URL, including username and password. Since you're hard-coding
the DB name anyway, just add it to the 'url' variable.
4. Your username and password validation: do you think that's sufficient
to see if either is null? Is an empty username OK?
5. If your code got multiple rows back from the 'userlogin' table it
wouldn't think that was a problem. Also, don't just copy code withoput
understanding it - just because you get a ResultSet doesn't mean you
have to also run a while() loop on it; if you expect one row and must
have one row, a while() loop would be clumsy and obscure that logic.
6. Don't - even in learning code - do that absolute noop with an
exception. Please.
AHS