'Join' two different field types together into a String - possible in Java?
Not entirely certain whether this is a straightforward Java or more of a JDBC question:
I have two fields, one is a String and one an integer. I need to concatenate these fields together to form one String, prior to performing an insert on a table. ie:
String s = dbRS.getString("partition_name");//get full string
String partstr = s.substring(0, 14);// get first 14 (alpha) characters
int new_partition_number = max_partition_number + 1;//create new unique partition number, incremented by 1
Now I have
- a String (partstr - i.e. "TN1234567890_")
- an integer (i.e. 50)
(NB. The number has to be an integer because it is subject to calculation elsewhere.)
I wish to join these together into a String ("TN1234567890_50") and use the field in an inserted row. I've tried using
String partition_string =new StringBuffer(partstr).append(new_partition_number ).toString();
... but this doesn't work.
I read on a forum that it's impossible to cast an integer to a String in this way in Java, which sounds pretty incredulous from where I am! However my Osborne Java 2 Complete Reference doesn't mention it at all.
Any assistance will be very gratefully received!
Thanks.

