1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public void InsertProjet(String location,String img) throws Exception
{
....
String req = "insert into projet values(0,'"+this.getnprojet()+
"','"+this.getnom_projet()+
"','"+this.getdd()+
"','"+this.getdf()+
"','"+this.getidentifient()+
"',?,?)";
PreparedStatement pStmt = conn.prepareStatement(req);
pStmt.setString(1, img);
// Lire le fichier et l'ajouter à l'instruction SQl
File fichier = new File(location);
FileReader reader = new FileReader(fichier);
pStmt.setCharacterStream(2, reader, (int) fichier.length());
// Exécuter les requêtes préparées
pStmt.execute();
} |
Partager