Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static Blob generateDecodedBlob(String encodedData, Connection connection) throws SQLException {
- logCreatingBlob(encodedData.length());
- long start = System.currentTimeMillis();
- Blob blob = connection.createBlob();
- Logger.info("decoding base64 bytes");
- Base64 codec = new Base64();
- byte[] decoded = codec.decode(encodedData.getBytes());
- blob.setBytes(1, decoded);
- Logger.info("decoded.");
- Logger.info("BLOB created in %d milliseconds", System.currentTimeMillis() - start);
- return blob;
- }
- private static void logCreatingBlob(int size) {
- BigDecimal bg = new BigDecimal(((float) size) / ((1024 * 1024)));
- bg = bg.setScale(2, BigDecimal.ROUND_HALF_UP);
- Logger.info("Creating BLOB of " + size + " Bytes " + bg.floatValue() + " MegaBytes");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement