I have a problem reading a blob from a MySQL database with Java.
I need to write a webservice with jax-rs to deliver an image saved in the database. For transport, it has to be encoded using Base64.
This is my code:
public String getImage(@PathParam("id") int id) throws SQLException{
System.out.println(id);
String img64str = "null";
Blob image = null;
Connection conn = MySQLConnection.getInstance();
if(conn != null)
{
try{
// Anfrage-Statement erzeugen.
Statement query;
query = conn.createStatement();
// Ergebnistabelle erzeugen und abholen.
String sql = "SELECT bild FROM beitraege where id