В JDBC вашият SQL израз не трябва да завършва с точка и запетая.
Промяна
String command = "SELECT distinct fname, lname, student_id FROM student"+
" where degree='"+ degree + "';";
до
String command = "SELECT distinct fname, lname, student_id FROM student"+
" where degree='"+ degree + "'";