hw to convert sms into database query??

hello sir,
I am going to make an application in java for the college project.
Application is about to get attendance of students via SMS.
1> if students send specific SMS to predefined number, he would get his attendance via SMS reply.

So,my question is that, how can i convert this SMS request into database query to get attendance and reply to them via SMS.?????