Advertisement
Guest User

Untitled

a guest
Mar 8th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public class ExtraOefening1 {
  2.  
  3. public static void main(String[] args) {
  4. Connection con = Oefening7.getConnection();
  5. try {
  6. PreparedStatement s = con.prepareStatement("INSERT INTO Images(imgName,img) VALUES(?,?)");
  7. File fBlob = new File("src/main/resources/bmp.bmp");
  8.  
  9. FileInputStream is = new FileInputStream(fBlob);
  10. s.setString(1, "image");
  11. s.setBlob(2, is);
  12. s.executeUpdate();
  13. } catch (Exception ex) {
  14. ex.printStackTrace();
  15. }
  16. }
  17. }
  18.  
  19.  
  20.  
  21. public class Oefening6 {
  22.  
  23. public static Connection getConnection() {
  24. try {
  25. Connection con = DriverManager.getConnection("jdbc:mysql://db4free.net/pxlboyen", "root12", "root12");
  26. return con;
  27. } catch (Exception ex) {
  28. System.out.println("oops");
  29.  
  30. ex.printStackTrace(System.err);
  31.  
  32. }
  33. return null;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement