I have a Java program that needs to access a database in Firebird with encoding DOS437.
I need convert the result of a query to UTF8, How can I do this?
My code in java:
public List<Proceso> ObtenerListaProcesos() throws SQLException {
List<Proceso> procesos = new ArrayList<>();
Proceso proceso = null;
Connection conn = null;
ResultSet rs = null;
String query = "select * from procesos where prc_web='V' and prc_valido='V' and prc_valido_fabrica='V' and prc_suplemento_Acabado='F' and prc_codigo!='-' order by prc_descripcion;";
String textoProceso="";
try {
conn = this.abrirConexion();
PreparedStatement p = conn.prepareStatement(query);
rs = p.executeQuery();
while (rs.next()) {
proceso = new Proceso(rs.getString("PRC_CODIGO"),
rs.getString("PRC_DESCRIPCION"));
procesos.add(proceso);
}
} catch (Exception e) {
log.error("Error en ObtenerListaProcesos: " + e.getMessage());
} finally {
this.cerrarConexion(conn);
}
return procesos;
}
I've an encoding in the firebird connection:
<conexionServidor>jdbc:firebirdsql:servidor/3050:F:/apps/GESTIONGYM2004/BD/BDGYM.FDB</conexionServidor>
<userBD>SYSDBA</userBD>
<passBD>masterkey</passBD>
<encodingBD>DOS437</encodingBD>
I need write the result of query in utf-8 to show in html file, but if use : new String(rs.getBytes("columnname"), "Cp437"), the result is not in UTF-8.