Advertisement
XploreLP

Untitled

Mar 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. public static int executeBlob(String query, byte[] bytes){
  2.         try
  3.         {
  4.           PreparedStatement stmt = getConnection().prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
  5.           Blob blob = getConnection().createBlob();
  6.           blob.setBytes(1, bytes);
  7.           stmt.setBlob(1, blob);
  8.           stmt.executeUpdate();
  9.           ResultSet result = stmt.getGeneratedKeys();
  10.           result.next();
  11.           return result.getInt(1);
  12.         }
  13.         catch (SQLException e)
  14.         {
  15.           e.printStackTrace();
  16.         }
  17.         return 0;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement