Salut les développeurs besoin de vous s’il vous plait !!
Je suis sous java et ma base de donnée et sous postgrsql ,j’ai une table x qui contient plusieurs champs le dernier est une image (type blob) j’arrive bien à l’insérer mais je n’arrive pas à la récupérer voici la portion du code de récupération et au dessous je mis l’exception affichée

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
 
 
 try {
             // TODO add your handling code here:
             int cc=Integer.parseInt(c.getText());
 
             String UrlBase = "jdbc:postgresql://localhost:5432/gestion";
             String driver="org.postgresql.Driver";
             String user = "postgres";
             String MDP="xxx";
             Statement stmtt;
 
             String sql;
             ResultSet rs ;
             sql = "SELECT image FROM x where code="+cc;
             Connection conn = DriverManager.getConnection(UrlBase, user,MDP);   
             stmtt = conn.createStatement();
             rs = stmtt.executeQuery(sql);
 
 
 
             Blob blob = null;
             Image img = null;
            // blob = rs.getBlob("image");
 
                 while(rs.next()){
 
           blob = rs.getBlob("image");
 
                 }
 
             img = ImageIO.read(blob.getBinaryStream());
         } catch (SQLException ex) {
             Logger.getLogger(DossierPatient.class.getName()).log(Level.SEVERE, null, ex);
         } catch (IOException ex) {
             Logger.getLogger(DossierPatient.class.getName()).log(Level.SEVERE, null, ex);
         }
l’exception:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
sept. 08, 2015 9:24:09 PM vues.DossierPatient pièceMouseClicked
GRAVE: null
org.postgresql.util.PSQLException: Mauvaise valeur pour le type long*: \015\012package CLASSE;\015\012\015\012/**\015\012 *\015\012 * @author user\015\012 */\015\012public class Patient {\015\012\015\012    \015\012    \015\012\015\012int codePatient;\015\012String nom;\015\012String prenom;\015\012String date;\015\012String lieu;\015\012String sexe;\015\012String adresse;\015\012String numeroTel;\015\012String activite;\015\012String pj;\015\012\015\012public Patient(int codePatient,String nom,String prenom,String date,String lieu,String sexe,String adresse,String numeroTel,String activit\351,String pj){\015\012    \015\012this.codePatient=codePatient;\015\012this.nom=nom;\015\012this.prenom=prenom;\015\012this.date=date;\015\012this.lieu=lieu;\015\012this.sexe=sexe;\015\012this.adresse=adresse;\015\012this.numeroTel=numeroTel;\015\012this.activite=activite;\015\012this.pj=pj;\015\012    }\015\012    \015\012String a;\015\012    public String _insert(){\015\012 return("INSERT INTO Patient "\015\012  \011\011+"VALUES('"+nom+"','"+prenom+"','"+date+"','"+lieu+"','"+sexe+"','"+activite+"','"+adresse+"','"+numeroTel+"','"+pj+"','"+codePatient+"');");\015\012\015\012\015\012} \015\012\015\012    public String _Afficher(){\015\012        \015\012        return("SELECT * FROM patient");\015\012        \015\012        \015\012        \015\012    }\015\012    \015\012}\015\012\015\012
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toLong(AbstractJdbc2ResultSet.java:2737)
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:2033)
	at org.postgresql.jdbc4.Jdbc4ResultSet.getBlob(Jdbc4ResultSet.java:52)
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBlob(AbstractJdbc2ResultSet.java:338)
	at vues.DossierPatient.pièceMouseClicked(DossierPatient.java:1751)
.......
psDossierPatient.java:1751)------> blob = rs.getBlob("image");

merci d'avance pour votre aide et pour vos idées précieuses

cordialement