If I understand correctly (if I don't you should have provided a better explanation) you want to insert a new order in a database?
If yes there is an SQL command when you create a table where you set the Primary Key to be auto increment so when a new row is inserted the key will have a sequence number. Try to search how to create a "sequence" and how to get the next value at an SQL forum or at the internet.
If you want the String "GB" next to the number, then create the table like normal with a primary key, then declare the "sequence" and whenever you want to insert write a select that gets the next number and add to it the String "GB". Then use this value as order ID.
Of course everything is based on assuming that this was what you wanted to know. If I am wrong provide better explanation.
If I was right but you don't understand what I am saying it's my fault. Ask for better explanation at an SQL forum
Try to understand this code - It's string operation.
String old="GB0001"; // Assume that this value is come from Database
String newstr="GB" + String.format(format,no);