Your statement is probably throwing an error because you are not quoting literals.
Instead of this code:
String query=("select username,password from users where username="+uname);
Try with:
String query=("select username,password from users where username='"+uname+"'");
Or better yet, use parameters in your queries by using a java.sql.PreparedStatement. Just google for java PreparedStatement
and you will find lots of examples.