JDBC - Character Encoding

Jdbc Class Architecture


Some JDBC driver manage the character encoding: Example:

  • MySQL: jdbc:mysql://localhost:3306/administer?characterEncoding=utf8
  • Oracle: See oracle.sql.CharacterSet class. By using NLS_LANG you can indicate which character set (encoding) at the OCI level.


The ResultSet.getString() method and PreparedStatement.setString() method expect string data in Java Unicode encoding (UTF-16).

To output the data in other encoding, use standard Java conversion mechanisms. Ex:

String outStr =  new String(rs.getBytes(1),"ISO-8859-1");

Share this page:
Follow us:
Task Runner