Di JDBC, pernyataan SQL Anda tidak boleh diakhiri dengan titik koma.
Ubah
String command = "SELECT distinct fname, lname, student_id FROM student"+
" where degree='"+ degree + "';";
untuk
String command = "SELECT distinct fname, lname, student_id FROM student"+
" where degree='"+ degree + "'";