1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
public static void storePic (){
try {
File image = new File("C:\\Users\\sony\\Desktop\\blob.jpg");
FileInputStream stream = new FileInputStream(image);
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe","user","mdp");
String sql = "INSERT INTO blobb VALUES (?, ?)";
PreparedStatement statement = connection.prepareStatement(sql);
statement.setInt(1, 8);
statement.setBinaryStream(2, stream, (int)image.length());
statement.executeUpdate(); // cette instruction génère une erreur... pk?
statement.close();
} catch (Exception ex) {
System.out.println("Erreur");
}
} |
Partager