List of usage examples for java.sql Blob getBytes
byte[] getBytes(long pos, int length) throws SQLException;
From source file:cz.zcu.kiv.eegdatabase.logic.controller.experiment.MeasurationDataOutputController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { // ModelAndView mav = new ModelAndView("binaryView"); // There should always be set integer value in this field - it is generated by view, not by user int fileId = Integer.parseInt(request.getParameter("fileId")); DataFile data = dataFileDao.read(fileId); Blob b = data.getFileContent(); Person user = personDao.getPerson(ControllerUtils.getLoggedUserName()); Timestamp currentTimestamp = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()); History history = new History(); log.debug("Setting downloading data file"); history.setDataFile(data);//from w w w . j a v a 2 s.co m log.debug("Setting user"); history.setPerson(user); log.debug("Setting time of download"); history.setDateOfDownload(currentTimestamp); log.debug("Saving download history"); historyDao.create(history); response.setHeader("Content-Type", data.getMimetype()); response.setHeader("Content-Disposition", "attachment;filename=" + data.getFilename()); response.getOutputStream().write(b.getBytes(1, (int) b.length())); // mav.addObject("dataObject", dataFileDao.read(fileId)); return null; }
From source file:edu.clemson.cs.nestbed.server.adaptation.sql.MoteTypeSqlAdapter.java
public Map<Integer, MoteType> readMoteTypes() throws AdaptationException { Map<Integer, MoteType> moteTypes = new HashMap<Integer, MoteType>(); Connection connection = null; Statement statement = null;/*from w w w.jav a 2 s .com*/ ResultSet resultSet = null; try { String query = "SELECT * FROM MoteTypes"; connection = DriverManager.getConnection(CONN_STR); statement = connection.createStatement(); resultSet = statement.executeQuery(query); while (resultSet.next()) { int id; String name; int totalROM; int totalRAM; int totalEEPROM; Blob imageBlob; String tosPlatform; Date timestamp; id = resultSet.getInt(Index.ID.index()); name = resultSet.getString(Index.NAME.index()); totalROM = resultSet.getInt(Index.TOTALROM.index()); totalRAM = resultSet.getInt(Index.TOTALRAM.index()); totalEEPROM = resultSet.getInt(Index.TOTALEEPROM.index()); imageBlob = resultSet.getBlob(Index.IMAGE.index()); tosPlatform = resultSet.getString(Index.TOSPLATFORM.index()); timestamp = resultSet.getDate(Index.TIMESTAMP.index()); byte[] image = (imageBlob != null && imageBlob.length() > 0) ? imageBlob.getBytes(1, (int) imageBlob.length()) : null; MoteType moteType = MoteType.getMoteType(id, name, totalROM, totalRAM, totalEEPROM, image, tosPlatform, timestamp); moteTypes.put(id, moteType); } } catch (SQLException ex) { String msg = "SQLException in readMoteTypes"; log.error(msg, ex); throw new AdaptationException(msg, ex); } finally { try { resultSet.close(); } catch (Exception ex) { } try { statement.close(); } catch (Exception ex) { } try { connection.close(); } catch (Exception ex) { } } return moteTypes; }
From source file:org.osaf.cosmo.migrate.ZeroPointFiveToZeroPointSixMigration.java
private void migrateEvents(Connection conn, String dialect) throws Exception { PreparedStatement stmt = null; PreparedStatement insertStampStmt1 = null; PreparedStatement insertStampStmt2 = null; PreparedStatement insertEventStmt = null; PreparedStatement insertAttributeStmt1 = null; PreparedStatement insertAttributeStmt2 = null; PreparedStatement deleteContentDataStmt = null; PreparedStatement selectContentDataStmt = null; PreparedStatement updateEventStmt = null; PreparedStatement updatePropsStmt = null; PreparedStatement updateTimerangesStmt = null; ResultSet rs = null;//www . ja v a2 s.c om long count = 0; System.setProperty("ical4j.unfolding.relaxed", "true"); CalendarBuilder calBuilder = new CalendarBuilder(); VersionFourGenerator uidGenerator = new VersionFourGenerator(); log.debug("begin migrateEvents()"); try { stmt = conn.prepareStatement("select id, contentdataid from item where itemtype=?"); stmt.setString(1, "event"); insertStampStmt1 = conn .prepareStatement("insert into stamp (stamptype, itemid, isactive) values (?,?,1)"); insertStampStmt1.setString(1, "event"); insertStampStmt2 = conn .prepareStatement("insert into stamp (stamptype, itemid, id, isactive) values (?,?,?,1)"); insertStampStmt2.setString(1, "event"); insertAttributeStmt1 = conn.prepareStatement( "insert into attribute (attributetype, namespace, localname, itemid, textvalue, attributename) values (?,?,?,?,?,'a')"); insertAttributeStmt2 = conn.prepareStatement( "insert into attribute (attributetype, namespace, localname, itemid, textvalue, id, attributename) values (?,?,?,?,?,?,'a')"); insertAttributeStmt1.setString(1, "text"); insertAttributeStmt2.setString(1, "text"); insertAttributeStmt1.setString(2, "org.osaf.cosmo.model.NoteItem"); insertAttributeStmt2.setString(2, "org.osaf.cosmo.model.NoteItem"); insertAttributeStmt1.setString(3, "body"); insertAttributeStmt2.setString(3, "body"); deleteContentDataStmt = conn.prepareStatement("delete from content_data where id=?"); selectContentDataStmt = conn.prepareStatement("select content from content_data where id=?"); updateEventStmt = conn.prepareStatement( "update item set itemtype=?, contentdataid=?, contentlength=?, icaluid=?, displayname=? where id=?"); updateEventStmt.setString(1, "note"); updateEventStmt.setNull(2, Types.BIGINT); insertEventStmt = conn.prepareStatement("insert into event_stamp (stampid, icaldata) values (?,?)"); updatePropsStmt = conn.prepareStatement("update cal_property_index set eventstampid=? where itemid=?"); updateTimerangesStmt = conn .prepareStatement("update cal_timerange_index set eventstampid=? where itemid=?"); rs = stmt.executeQuery(); while (rs.next()) { count++; long itemId = rs.getLong(1); long contentDataId = rs.getLong(2); long stampId = 0; // Add record to stamp if ("MySQL5".equals(dialect)) { insertStampStmt1.setLong(2, itemId); insertStampStmt1.executeUpdate(); } else { stampId = hibernateHelper.getNexIdUsingHiLoGenerator(conn); insertStampStmt2.setLong(2, itemId); insertStampStmt2.setLong(3, stampId); insertStampStmt2.executeUpdate(); } // MySQL uses autogenerated id if ("MySQL5".equals(dialect)) { ResultSet generatedKeysRs = insertStampStmt1.getGeneratedKeys(); generatedKeysRs.next(); stampId = generatedKeysRs.getLong(1); generatedKeysRs.close(); } // Get binary content data selectContentDataStmt.setLong(1, contentDataId); Calendar calendar = null; long icalLength = 0; String icalUid = null; String eventDesc = null; String eventSummary = null; ResultSet contentDataRs = selectContentDataStmt.executeQuery(); if (contentDataRs.next()) { log.debug("itemid=" + itemId); Blob icalBlob = contentDataRs.getBlob(1); byte[] icalBytes = icalBlob.getBytes(1, (int) icalBlob.length()); // have to parse data into Calendar to get right contentlength calendar = calBuilder.build(new ByteArrayInputStream(icalBytes)); VEvent event = (VEvent) calendar.getComponents().getComponents(Component.VEVENT).get(0); // Now that we parsed, lets get the UID, DESCRIPTION, and // SUMMARY so we can update NoteItem, ContentItem Uid uid = event.getUid(); // Handle the case where events don't have a UID (should be rare) if (uid != null) icalUid = event.getUid().getValue(); if (icalUid == null || "".equals(icalUid)) icalUid = null; // If there is no UID, create a new one if (icalUid == null) { icalUid = uidGenerator.nextIdentifier().toString(); if (uid != null) uid.setValue(icalUid); else event.getProperties().add(new Uid(icalUid)); } Property p = event.getProperties().getProperty(Property.DESCRIPTION); if (p != null) eventDesc = p.getValue(); if ("".equals(eventDesc)) eventDesc = null; p = event.getProperties().getProperty(Property.SUMMARY); if (p != null) eventSummary = p.getValue(); if ("".equals(eventSummary)) eventSummary = null; // Make sure we can fit summary in displayname column if (eventSummary != null && eventSummary.length() >= 255) eventSummary = eventSummary.substring(0, 254); // Calculate new length icalLength = calendar.toString().getBytes("UTF-8").length; } contentDataRs.close(); // update item record with new contentLength, itemtype, // icaluid, and displayname updateEventStmt.setLong(3, icalLength); updateEventStmt.setString(4, icalUid); if (eventSummary != null) updateEventStmt.setString(5, eventSummary); else updateEventStmt.setNull(5, Types.VARCHAR); updateEventStmt.setLong(6, itemId); updateEventStmt.executeUpdate(); // add event_stamp record insertEventStmt.setLong(1, stampId); insertEventStmt.setString(2, calendar.toString()); insertEventStmt.executeUpdate(); // If there is a DESCRIPTION, add a text attribute if (eventDesc != null) { if ("MySQL5".equals(dialect)) { insertAttributeStmt1.setLong(4, itemId); insertAttributeStmt1.setString(5, eventDesc); insertAttributeStmt1.executeUpdate(); } else { long attributeId = hibernateHelper.getNexIdUsingHiLoGenerator(conn); insertAttributeStmt2.setLong(4, itemId); insertAttributeStmt2.setString(5, eventDesc); insertAttributeStmt2.setLong(6, attributeId); insertAttributeStmt2.executeUpdate(); } } // Update calendar indexes to reflect item and stamp updatePropsStmt.setLong(1, stampId); updatePropsStmt.setLong(2, itemId); updatePropsStmt.executeUpdate(); updateTimerangesStmt.setLong(1, stampId); updateTimerangesStmt.setLong(2, itemId); updateTimerangesStmt.executeUpdate(); // no longer need content for events deleteContentDataStmt.setLong(1, contentDataId); deleteContentDataStmt.executeUpdate(); } } finally { if (rs != null) rs.close(); if (stmt != null) stmt.close(); if (insertStampStmt1 != null) insertStampStmt1.close(); if (insertStampStmt2 != null) insertStampStmt2.close(); if (insertAttributeStmt1 != null) insertAttributeStmt1.close(); if (insertAttributeStmt2 != null) insertAttributeStmt2.close(); if (deleteContentDataStmt != null) deleteContentDataStmt.close(); if (selectContentDataStmt != null) selectContentDataStmt.close(); if (updateEventStmt != null) updateEventStmt.close(); if (insertEventStmt != null) insertEventStmt.close(); if (updatePropsStmt != null) updatePropsStmt.close(); if (updateTimerangesStmt != null) updateTimerangesStmt.close(); } log.debug("processed " + count + " events"); }
From source file:com.healthmarketscience.jackcess.impl.ColumnImpl.java
/** * @return an appropriate byte[] representation of the given object. * @usage _advanced_method_/*from w w w. ja v a 2s .c o m*/ */ public static byte[] toByteArray(Object value) throws IOException { if (value == null) { return null; } else if (value instanceof byte[]) { return (byte[]) value; } else if (value instanceof OleUtil.OleBlobImpl) { return ((OleUtil.OleBlobImpl) value).getBytes(); } else if (value instanceof Blob) { try { Blob b = (Blob) value; // note, start pos is 1-based return b.getBytes(1L, (int) b.length()); } catch (SQLException e) { throw (IOException) (new IOException(e.getMessage())).initCause(e); } } ByteArrayOutputStream bout = new ByteArrayOutputStream(); if (value instanceof InputStream) { ByteUtil.copy((InputStream) value, bout); } else { // if all else fails, serialize it ObjectOutputStream oos = new ObjectOutputStream(bout); oos.writeObject(value); oos.close(); } return bout.toByteArray(); }
From source file:org.wso2.carbon.cluster.coordinator.rdbms.RDBMSCommunicationBusContextImpl.java
@Override public NodeDetail getRemovedNodeData(String nodeId, String groupId, String removedMemberId) throws ClusterCoordinationException { Connection connection = null; PreparedStatement preparedStatement = null; PreparedStatement clearMembershipEvents = null; ResultSet resultSet = null;//from w ww. j a v a 2 s.com NodeDetail nodeDetail = null; try { connection = getConnection(); preparedStatement = connection.prepareStatement(RDBMSConstants.PS_SELECT_REMOVED_MEMBER_DETAILS); preparedStatement.setString(1, nodeId); preparedStatement.setString(2, removedMemberId); preparedStatement.setString(3, groupId); resultSet = preparedStatement.executeQuery(); Map<String, Object> propertiesMap = null; if (resultSet.next()) { Blob blob = resultSet.getBlob(2); if (blob != null) { int blobLength = (int) blob.length(); byte[] bytes = blob.getBytes(1, blobLength); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bis); Object blobObject = ois.readObject(); if (blobObject instanceof Map) { propertiesMap = (Map) blobObject; } } nodeDetail = new NodeDetail(removedMemberId, groupId, false, 0, false, propertiesMap); } clearMembershipEvents = connection .prepareStatement(RDBMSConstants.PS_DELETE_REMOVED_MEMBER_DETAIL_FOR_NODE); clearMembershipEvents.setString(1, nodeId); clearMembershipEvents.setString(2, removedMemberId); clearMembershipEvents.setString(3, groupId); clearMembershipEvents.executeUpdate(); connection.commit(); } catch (SQLException e) { String errMsg = RDBMSConstants.TASK_GET_ALL_QUEUES; throw new ClusterCoordinationException("Error occurred while " + errMsg, e); } catch (ClassNotFoundException e) { throw new ClusterCoordinationException("Error retrieving the removed node data. ", e); } catch (IOException e) { throw new ClusterCoordinationException("Error retrieving the removed node data. ", e); } finally { close(resultSet, RDBMSConstants.TASK_GET_ALL_QUEUES); close(preparedStatement, RDBMSConstants.TASK_GET_ALL_QUEUES); close(clearMembershipEvents, RDBMSConstants.TASK_GET_ALL_QUEUES); close(connection, RDBMSConstants.TASK_GET_ALL_QUEUES); } return nodeDetail; }
From source file:org.apache.james.mailrepository.jdbc.JDBCMailRepository.java
/** * @see org.apache.james.mailrepository.api.MailRepository#retrieve(String) *//*from w w w .ja v a2s . c o m*/ @SuppressWarnings("unchecked") public Mail retrieve(String key) throws MessagingException { if (DEEP_DEBUG) { System.err.println("retrieving " + key); } Connection conn = null; PreparedStatement retrieveMessage = null; ResultSet rsMessage = null; try { conn = datasource.getConnection(); if (DEEP_DEBUG) { System.err.println("got a conn " + key); } retrieveMessage = conn.prepareStatement(sqlQueries.getSqlString("retrieveMessageSQL", true)); retrieveMessage.setString(1, key); retrieveMessage.setString(2, repositoryName); rsMessage = retrieveMessage.executeQuery(); if (DEEP_DEBUG) { System.err.println("ran the query " + key); } if (!rsMessage.next()) { if (getLogger().isDebugEnabled()) { String debugBuffer = "Did not find a record " + key + " in " + repositoryName; getLogger().debug(debugBuffer); } return null; } // Determine whether attributes are used and retrieve them PreparedStatement retrieveMessageAttr = null; HashMap<String, Object> attributes = null; if (jdbcMailAttributesReady) { String retrieveMessageAttrSql = sqlQueries.getSqlString("retrieveMessageAttributesSQL", false); ResultSet rsMessageAttr = null; try { retrieveMessageAttr = conn.prepareStatement(retrieveMessageAttrSql); retrieveMessageAttr.setString(1, key); retrieveMessageAttr.setString(2, repositoryName); rsMessageAttr = retrieveMessageAttr.executeQuery(); if (rsMessageAttr.next()) { try { byte[] serialized_attr; String getAttributesOption = sqlQueries.getDbOption("getAttributes"); if (getAttributesOption != null && (getAttributesOption.equalsIgnoreCase("useBlob") || getAttributesOption.equalsIgnoreCase("useBinaryStream"))) { Blob b = rsMessageAttr.getBlob(1); serialized_attr = b.getBytes(1, (int) b.length()); } else { serialized_attr = rsMessageAttr.getBytes(1); } // this check is for better backwards compatibility if (serialized_attr != null) { ByteArrayInputStream bais = new ByteArrayInputStream(serialized_attr); ObjectInputStream ois = new ObjectInputStream(bais); attributes = (HashMap<String, Object>) ois.readObject(); ois.close(); } } catch (IOException ioe) { if (getLogger().isDebugEnabled()) { String debugBuffer = "Exception reading attributes " + key + " in " + repositoryName; getLogger().debug(debugBuffer, ioe); } } } else { if (getLogger().isDebugEnabled()) { String debugBuffer = "Did not find a record (attributes) " + key + " in " + repositoryName; getLogger().debug(debugBuffer); } } } catch (SQLException sqle) { String errorBuffer = "Error retrieving message" + sqle.getMessage() + sqle.getErrorCode() + sqle.getSQLState() + sqle.getNextException(); getLogger().error(errorBuffer); } finally { theJDBCUtil.closeJDBCResultSet(rsMessageAttr); theJDBCUtil.closeJDBCStatement(retrieveMessageAttr); } } MailImpl mc = new MailImpl(); mc.setAttributesRaw(attributes); mc.setName(key); mc.setState(rsMessage.getString(1)); mc.setErrorMessage(rsMessage.getString(2)); String sender = rsMessage.getString(3); if (sender == null) { mc.setSender(null); } else { mc.setSender(new MailAddress(sender)); } StringTokenizer st = new StringTokenizer(rsMessage.getString(4), "\r\n", false); Set<MailAddress> recipients = new HashSet<MailAddress>(); while (st.hasMoreTokens()) { recipients.add(new MailAddress(st.nextToken())); } mc.setRecipients(recipients); mc.setRemoteHost(rsMessage.getString(5)); mc.setRemoteAddr(rsMessage.getString(6)); mc.setLastUpdated(rsMessage.getTimestamp(7)); MimeMessageJDBCSource source = new MimeMessageJDBCSource(this, key, sr); MimeMessageCopyOnWriteProxy message = new MimeMessageCopyOnWriteProxy(source); mc.setMessage(message); return mc; } catch (SQLException sqle) { String errorBuffer = "Error retrieving message" + sqle.getMessage() + sqle.getErrorCode() + sqle.getSQLState() + sqle.getNextException(); getLogger().error(errorBuffer); getLogger().debug("Failed to retrieve mail", sqle); throw new MessagingException("Exception while retrieving mail: " + sqle.getMessage(), sqle); } catch (Exception me) { throw new MessagingException("Exception while retrieving mail: " + me.getMessage(), me); } finally { theJDBCUtil.closeJDBCResultSet(rsMessage); theJDBCUtil.closeJDBCStatement(retrieveMessage); theJDBCUtil.closeJDBCConnection(conn); } }
From source file:org.zaproxy.zap.extension.websocket.db.TableWebSocket.java
/** * @param rs/*from w w w . j av a 2 s.com*/ * @param interpretLiteralBytes * @param payloadLength * @return * @throws HttpMalformedHeaderException * @throws SQLException * @throws DatabaseException */ private List<WebSocketMessageDTO> buildMessageDTOs(ResultSet rs, boolean interpretLiteralBytes, int payloadLength) throws SQLException, DatabaseException { ArrayList<WebSocketMessageDTO> messages = new ArrayList<>(); try { while (rs.next()) { WebSocketMessageDTO message; int channelId = rs.getInt("channel_id"); WebSocketChannelDTO channel = getChannel(channelId); if (rs.getInt("fuzz_id") != 0) { WebSocketFuzzMessageDTO fuzzMessage = new WebSocketFuzzMessageDTO(channel); fuzzMessage.fuzzId = rs.getInt("fuzz_id"); fuzzMessage.state = WebSocketFuzzMessageDTO.State.valueOf(rs.getString("state")); fuzzMessage.fuzz = rs.getString("fuzz"); message = fuzzMessage; } else { message = new WebSocketMessageDTO(channel); } message.id = rs.getInt("message_id"); message.setTime(rs.getTimestamp("timestamp")); message.opcode = rs.getInt("opcode"); message.readableOpcode = WebSocketMessage.opcode2string(message.opcode); // read payload if (message.opcode == WebSocketMessage.OPCODE_BINARY) { if (payloadLength == -1) { // load all bytes message.payload = rs.getBytes("payload_bytes"); } else { Blob blob = rs.getBlob("payload_bytes"); int length = Math.min(payloadLength, (int) blob.length()); message.payload = blob.getBytes(1, length); blob.free(); } if (message.payload == null) { message.payload = new byte[0]; } } else { if (payloadLength == -1) { // load all characters message.payload = rs.getString("payload_utf8"); } else { Clob clob = rs.getClob("payload_utf8"); int length = Math.min(payloadLength, (int) clob.length()); message.payload = clob.getSubString(1, length); clob.free(); } if (message.payload == null) { message.payload = ""; } } message.isOutgoing = rs.getBoolean("is_outgoing"); message.payloadLength = rs.getInt("payload_length"); messages.add(message); } } finally { rs.close(); } messages.trimToSize(); return messages; }
From source file:com.cloudera.sqoop.testutil.ManagerCompatTestCase.java
protected void verifyBlob(String insertVal, byte[] returnVal, String seqFileVal) { String[] types = { "INTEGER NOT NULL", getBlobType() }; String[] vals = { "1", insertVal }; String[] checkCols = { "DATA_COL0", "DATA_COL1" }; createTableWithColTypes(types, vals); // Verify readback of the data. ResultSet results = null;/*from www. j a va 2 s. c o m*/ try { results = getManager().readTable(getTableName(), getColNames()); assertNotNull("Null results from readTable()!", results); assertTrue("Expected at least one row returned", results.next()); Blob blob = results.getBlob(2); byte[] databaseBytes = blob.getBytes(1, (int) blob.length()); log.info("Verifying readback of bytes from " + getTableName()); assertEquals("byte arrays differ in size", returnVal.length, databaseBytes.length); for (int i = 0; i < returnVal.length; i++) { assertEquals("bytes differ at position " + i + ". Expected " + returnVal[i] + "; got " + databaseBytes[i], returnVal[i], databaseBytes[i]); } assertFalse("Expected at most one row returned", results.next()); } catch (SQLException sqlE) { fail("Got SQLException: " + sqlE.toString()); } finally { if (null != results) { try { results.close(); } catch (SQLException sqlE) { fail("Got SQLException in resultset.close(): " + sqlE.toString()); } } // Free internal resources after the readTable. getManager().release(); } // Now verify that we can use the Sqoop import mechanism on this data. verifyImport("1," + seqFileVal, checkCols); }
From source file:org.wso2.carbon.identity.certificateauthority.dao.CsrDAO.java
/** * constructs and returns a Csr array from a resultSet * * @param resultSet result set//from w ww .j a v a 2s . co m * @return array of CsrFiles */ private Csr[] getCsrArray(ResultSet resultSet) throws CaException, SQLException, IOException { ArrayList<Csr> csrList = new ArrayList<Csr>(); int count = 0; while (resultSet.next()) { String serialNo = resultSet.getString(Constants.SERIAL_NO_LABEL); String status = resultSet.getString(Constants.CSR_STATUS_LABEL); String commonName = resultSet.getString(Constants.CSR_COMMON_NAME_LABEL); String organization = resultSet.getString(Constants.CSR_ORGANIZATION_LABEL); Csr csrFile; String country = null; String department = null; String city = null; String state = null; Blob csrBlob = resultSet.getBlob(Constants.CSR_CONTENT_LABEL); Date requestedDate = resultSet.getTimestamp(Constants.CSR_REQUESTED_DATE); String username = resultSet.getString(Constants.CSR_REQUESTER_USERNAME_LABEL); int tenantID = resultSet.getInt(Constants.TENANT_ID_LABEL); String userStoreDomain = resultSet.getString(Constants.USER_STORE_DOMAIN_LABEL); PKCS10CertificationRequest csr = new PKCS10CertificationRequest( csrBlob.getBytes(1, (int) csrBlob.length())); HashMap decodedContent = CsrUtils.getSubjectInfo(csr); if (decodedContent.containsKey("C")) { country = decodedContent.get("C").toString(); } if (decodedContent.containsKey("L")) { city = decodedContent.get("L").toString(); } if (decodedContent.containsKey("OU")) { department = decodedContent.get("OU").toString(); } if (decodedContent.containsKey("ST")) { state = decodedContent.get("ST").toString(); } csrFile = new Csr(commonName, department, organization, city, state, country, csr, serialNo, status, username, tenantID, userStoreDomain, requestedDate); csrList.add(csrFile); } Csr[] csrs = new Csr[csrList.size()]; csrs = csrList.toArray(csrs); return csrs; }
From source file:gobblin.source.extractor.extract.jdbc.JdbcExtractor.java
private String readBlobAsString(Blob logBlob) throws SQLException { if (logBlob == null) { return StringUtils.EMPTY; }/*w ww .ja v a 2 s. c o m*/ byte[] ba = logBlob.getBytes(1L, (int) (logBlob.length())); if (ba == null) { return StringUtils.EMPTY; } String baString = Base64.encodeBase64String(ba); return baString; }