I think you want to extract 15 digit record id from database.
In salesforce, When we query for record id it always returns 18 digit ID. there is no way to get 15 digit record ID as far as i know. But we can use some function further to convert 18 digit ID into 15 digit id. like
String id = '01I90000000jJonJON'; //18 digit Id
String id15Digit = id.substring(0, 15); // will give you '01I90000000jJon' 15 digit id
substring(0, 15) as this will return 15 characters starting at the 0 index.
Below are few more points regarding 15 digit and 18 digit ids :
15 digit case-sensitive version which is referenced in the UI
18 digit case-insensitive version which is referenced through the API
The last 3 digits of the 18 digit ID are a checksum of the capitalizations of the first 15 characters, this ID length was created as a workaround to legacy systems which were not compatible with case-sensitive IDs.
The API will accept the 15 digit ID as input but will always return the 18 digit ID.