The encoding ASCII is a 7-bit encoding, namely, it just supports characters from 0-127.
My assignment says that I should use 8-bit encoding. Therefore I think
you should revise this.
Go over the list of
Supported Encodings.
I think the ISO-8859-X family are 8-bit encodings, as well as windows-1252
(aka Cp1252).
Now, you should use the encoding every time you
read a bunch of bytes from the database and you want to
convert them to a String, and also every time you want to
convert a String into a bunch of bytes to
write them back into the database.
If you use ASCII encoding you will only be able to represent as byte the first 128 characters, that is, you would be using just the first 7 bits of every character spectrum.
Whether you want to throw UnsupportedEncondingException or not is up to you and your design. In my case I absorb the exception and use the default encoding when this exception happens. However, I do that because when I try to create the database object I always check that the proposed encoding is supported using
java.nio.charset.Charset.isSupported(String) method. Therefore I am not expecting this exception to happen here.
[ October 26, 2006: Message edited by: Edwin Dalorzo ]