I have a database in Postgresql and using pgadmin4, there I have a table called products with 5 columns that contain the following types of data: Id, name, description, price, type. Now I want to add a column where I can save an image from its url to show in my project a list of products where I have all an image and descriptions of the product. This I am working on eclipse, I want to know what kind of data would be the image and how to insert it in the database. thanks
my code:
@RequestMapping ("/sakuraproductos")
static public String listadoProductos(Model template) throws SQLException {
Connection connection;
connection = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/blabla", "blablas",
"blabla");
PreparedStatement ps = connection
.prepareStatement(
"SELECT * FROM productos");
ResultSet result = ps.executeQuery();
ArrayList<Producto> listaProductos;
listaProductos = new ArrayList<Producto>();
while (result.next()) {
Producto a = new Producto(result.getString("nombre"),
result.getString("descripcion"),
result.getDouble("precio"), result.getString("tipo")
);
listaProductos.add (a);
}
template.addAttribute("productos", listaProductos);
connection.close();
return "sakuraproductos";
}