I have a big problem! when I do this:
String query = \"SELECT * FROM utente WHERE confermato=1 and Username=\'\" + username + \"\' AND Password
well we don't know how big your database is, but your query is pretty specific.
as for max_allowed_packet, check this post:
how to check and set max_allowed_packet mysql variable