Bonjour,
En plein développement d'application web, j'essai d'enregistrer des images dans ma BDD pour mes démos.
J'ai pu enregistrer un certains nombre d'image mais il y en a d'autres qui me créent des soucis.
J'obtiens une erreur de flux
Enregistrement produit échoué
ERROR BddService - Incapable de lier les valeurs des paramètres pour la commande.
org.postgresql.util.PSQLException: Incapable de lier les valeurs des paramètres pour la commande.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:277)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:321)
at ci.service.BddService.sauveIMG_PROD(BddService.java:140)
at ci.main.EnregistrementImage.main(EnregistrementImage.java:43)
Caused by: java.io.EOFException: Fin prématurée du flux en entrée, 34*404 octets attendus, mais seulement 17*224 lus.
at org.postgresql.core.PGStream.SendStream(PGStream.java:480)
at org.postgresql.core.v3.SimpleParameterList.streamBytea(SimpleParameterList.java:202)
at org.postgresql.core.v3.SimpleParameterList.writeV3Value(SimpleParameterList.java:285)
at org.postgresql.core.v3.QueryExecutorImpl.sendBind(QueryExecutorImpl.java:1293)
at org.postgresql.core.v3.QueryExecutorImpl.sendOneQuery(QueryExecutorImpl.java:1506)
at org.postgresql.core.v3.QueryExecutorImpl.sendQuery(QueryExecutorImpl.java:1062)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
... 5 more
D'après ce que je lis, Il y a certainement une erreur de lecture de fichiers.

voici un aperçu de ma méthode qui lance l'enregistrement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
/**Enregistrement dans la table des produits*/
	public void sauveIMG_PROD(String front, String back, String right,
			String left, String iconFront, String iconBack, String iconRight,
			String iconLeft, String nom) throws SQLException,
			FileNotFoundException, IOException {
		// TODO Auto-generated method stub
		File imageFront = new File(front);
		File imageBack = new File(back);
		File imageRight = new File(right);
		File imageLeft = new File(left);
		File icoFront = new File(iconFront);
		File icoBack = new File(iconBack);
		File icoRight = new File(iconRight);
		File icoLeft = new File(iconLeft);
		FileInputStream fisFront = new FileInputStream(imageFront);
		FileInputStream fisBack = new FileInputStream(imageBack);
		FileInputStream fisRight = new FileInputStream(imageRight);
		FileInputStream fisLeft = new FileInputStream(imageLeft);
		FileInputStream fisIcoFront = new FileInputStream(icoFront);
		FileInputStream fisIcoBack = new FileInputStream(icoBack);
		FileInputStream fisIcoRight = new FileInputStream(icoRight);
		FileInputStream fisIcoLeft = new FileInputStream(icoLeft);
		try {
			conn = initialiserConnexion();
			String sql = "insert into produit (nom, front, back, rights, lefts, frontc, backc, rightsc, leftsc) values (?,?,?,?,?,?,?,?,?)";
			PreparedStatement ps = conn.prepareStatement(sql);
			try {
				ps.setString(1, nom);
				ps.setBinaryStream(2, fisFront, (int) imageFront.length());
				ps.setBinaryStream(3, fisBack, (int) imageFront.length());
				ps.setBinaryStream(4, fisRight, (int) imageFront.length());
				ps.setBinaryStream(5, fisLeft, (int) imageFront.length());
				ps.setBinaryStream(6, fisIcoFront, (int) icoFront.length());
				ps.setBinaryStream(7, fisIcoBack, (int) icoBack.length());
				ps.setBinaryStream(8, fisIcoRight, (int) icoRight.length());
				ps.setBinaryStream(9, fisIcoLeft, (int) icoLeft.length());
				ps.executeUpdate();
			} catch (SQLException e) {
				LOGGER.error(e.getMessage(), e);
				arret("Enregistrement produit échoué");
			} finally {
				ps.close();
			}
		} finally {
			fisFront.close();
			fisBack.close();
			fisRight.close();
			fisLeft.close();
			fisIcoFront.close();
			fisIcoBack.close();
			fisIcoRight.close();
			fisIcoLeft.close();
		}
Merci pour votre aide