List of usage examples for java.sql ResultSet getBinaryStream
java.io.InputStream getBinaryStream(String columnLabel) throws SQLException;
ResultSet
object as a stream of uninterpreted byte
s. From source file:at.ac.tuwien.dsg.depic.orchestrator.elasticityprocessesstore.ElasticityProcessesStore.java
public QoRModel getQoRModel(String dataAssetID) { String qorXML = ""; try {/* w w w .j a va2 s. co m*/ InputStream inputStream = null; String sql = "SELECT * FROM InputSpecification, DataAssetFunction " + "WHERE InputSpecification.name = DataAssetFunction.edaas " + "AND DataAssetFunction.dataAssetID='" + dataAssetID + "'"; ResultSet rs = connectionManager.ExecuteQuery(sql); try { while (rs.next()) { inputStream = rs.getBinaryStream("elasticity_processes"); } } catch (SQLException ex) { Logger.getLogger(ElasticityProcessesStore.class.getName()).log(Level.SEVERE, null, ex); } StringWriter writer = new StringWriter(); String encoding = StandardCharsets.UTF_8.name(); IOUtils.copy(inputStream, writer, encoding); qorXML = writer.toString(); } catch (IOException ex) { Logger.getLogger(ElasticityProcessesStore.class.getName()).log(Level.SEVERE, null, ex); } QoRModel qoRModel = null; try { qoRModel = JAXBUtils.unmarshal(qorXML, QoRModel.class); } catch (JAXBException ex) { Logger.getLogger(ElasticityProcessesStore.class.getName()).log(Level.SEVERE, null, ex); } return qoRModel; }
From source file:org.pentaho.platform.repository.hibernate.usertypes.BlobUserType.java
public Object nullSafeGet(final ResultSet arg0, final String[] arg1, final Object arg2) throws HibernateException, SQLException { if (BlobUserType.debug) { BlobUserType.log.debug(Messages.getInstance().getString("BLOBUTYPE.DEBUG_NULL_SAFE_GET")); //$NON-NLS-1$ }//from www . ja v a 2s. com InputStream is = arg0.getBinaryStream(arg1[0]); if (is != null) { return SerializationHelper.deserialize(is); } return null; }
From source file:at.ac.tuwien.dsg.depic.common.repository.ElasticProcessRepositoryManager.java
public String getDAF(String edaas) { String sql = "SELECT * FROM InputSpecification WHERE name='" + edaas + "'"; String dafStr = ""; ResultSet rs = connectionManager.ExecuteQuery(sql); try {/*from w ww . ja v a 2 s .c o m*/ while (rs.next()) { InputStream inputStream = rs.getBinaryStream("daf"); StringWriter writer = new StringWriter(); String encoding = StandardCharsets.UTF_8.name(); IOUtils.copy(inputStream, writer, encoding); dafStr = writer.toString(); } rs.close(); } catch (Exception ex) { System.err.println(ex); } return dafStr; }
From source file:at.ac.tuwien.dsg.depic.common.repository.ElasticProcessRepositoryManager.java
public String getElasticityProcesses(String eDaaSName) { String sql = "SELECT * FROM ElasticDaaS WHERE name='" + eDaaSName + "'"; String elProcessXML = ""; ResultSet rs = connectionManager.ExecuteQuery(sql); try {//from w ww . j ava 2 s .c o m while (rs.next()) { InputStream inputStream = rs.getBinaryStream("elasticity_processes"); StringWriter writer = new StringWriter(); String encoding = StandardCharsets.UTF_8.name(); IOUtils.copy(inputStream, writer, encoding); elProcessXML = writer.toString(); } rs.close(); } catch (Exception ex) { System.err.println(ex); } return elProcessXML; }
From source file:at.ac.tuwien.dsg.depic.common.repository.ElasticProcessRepositoryManager.java
public String getQoR(String edaas) { String sql = "SELECT * FROM InputSpecification WHERE name='" + edaas + "'"; String qorStr = ""; ResultSet rs = connectionManager.ExecuteQuery(sql); try {//from w ww . j a v a 2 s . c om while (rs.next()) { InputStream inputStream = rs.getBinaryStream("qor"); StringWriter writer = new StringWriter(); String encoding = StandardCharsets.UTF_8.name(); IOUtils.copy(inputStream, writer, encoding); qorStr = writer.toString(); } rs.close(); } catch (Exception ex) { System.err.println(ex); } return qorStr; }
From source file:at.ac.tuwien.dsg.orchestrator.elasticityprocessesstore.ElasticityProcessesStore.java
public PrimitiveActionMetadata getPrimitiveActionMetadata(String eDaaSName) { String sql = "SELECT * FROM InputSpecification WHERE name ='" + eDaaSName + "'"; InputStream inputStream = null; String primitiveXML = ""; ResultSet rs = connectionManager.ExecuteQuery(sql); try {/*from w w w.ja v a 2s . c o m*/ while (rs.next()) { inputStream = rs.getBinaryStream("elasticity_process_config"); } StringWriter writer = new StringWriter(); String encoding = StandardCharsets.UTF_8.name(); IOUtils.copy(inputStream, writer, encoding); primitiveXML = writer.toString(); } catch (Exception ex) { } PrimitiveActionMetadata primitiveActionMetadata = YamlUtils.unmarshallYaml(PrimitiveActionMetadata.class, primitiveXML); return primitiveActionMetadata; }
From source file:at.ac.tuwien.dsg.orchestrator.elasticityprocessesstore.ElasticityProcessesStore.java
public String getElasticityProcesses(String eDaaSName) { String sql = "SELECT * FROM ElasticDaaS WHERE name='" + eDaaSName + "'"; String elProcessXML = ""; ResultSet rs = connectionManager.ExecuteQuery(sql); try {// w w w .j av a 2 s .com while (rs.next()) { InputStream inputStream = rs.getBinaryStream("elasticity_processes"); StringWriter writer = new StringWriter(); String encoding = StandardCharsets.UTF_8.name(); IOUtils.copy(inputStream, writer, encoding); elProcessXML = writer.toString(); } rs.close(); } catch (Exception ex) { } return elProcessXML; }
From source file:nz.co.gregs.dbvolution.datatypes.DBJavaObject.java
@SuppressWarnings("unchecked") private O getFromBinaryStream(ResultSet resultSet, String fullColumnName) throws SQLException { O returnValue = null;//from ww w .j a va 2 s . c om InputStream inputStream; inputStream = resultSet.getBinaryStream(fullColumnName); if (resultSet.wasNull()) { inputStream = null; } if (inputStream == null) { this.setToNull(); } else { final BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); try { ObjectInputStream input = new ObjectInputStream(bufferedInputStream); try { returnValue = (O) input.readObject(); } finally { input.close(); } } catch (IOException ex) { Logger.getLogger(DBJavaObject.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(DBJavaObject.class.getName()).log(Level.SEVERE, null, ex); } } return returnValue; }
From source file:at.ac.tuwien.dsg.depic.orchestrator.elasticityprocessesstore.ElasticityProcessesStore.java
public ElasticDataAsset getElasticDataAsset(String edaasName) { String elasticityProcessesXML = ""; String elasticStateSetXML = ""; try {//www . j a v a 2s . c om InputStream elProcessStream = null; InputStream eStateSetStream = null; InputStream typeStream = null; String sql = "SELECT * FROM ElasticDaaS " + "WHERE ElasticDaaS.name='" + edaasName + "' "; ResultSet rs = connectionManager.ExecuteQuery(sql); try { while (rs.next()) { elProcessStream = rs.getBinaryStream("elasticity_processes"); eStateSetStream = rs.getBinaryStream("elasticStateSet"); typeStream = rs.getBinaryStream("type"); } } catch (SQLException ex) { Logger.getLogger(ElasticityProcessesStore.class.getName()).log(Level.SEVERE, null, ex); } StringWriter writer1 = new StringWriter(); String encoding = StandardCharsets.UTF_8.name(); IOUtils.copy(elProcessStream, writer1, encoding); elasticityProcessesXML = writer1.toString(); StringWriter writer2 = new StringWriter(); IOUtils.copy(eStateSetStream, writer2, encoding); elasticStateSetXML = writer2.toString(); StringWriter writer3 = new StringWriter(); IOUtils.copy(typeStream, writer3, encoding); String typeStr = writer3.toString(); } catch (IOException ex) { Logger.getLogger(ElasticityProcessesStore.class.getName()).log(Level.SEVERE, null, ex); } Configuration cfg = new Configuration( getClass().getProtectionDomain().getCodeSource().getLocation().getPath()); YamlUtils.setFilePath(cfg.getConfigPath()); DataElasticityManagementProcess elasticityProcess = YamlUtils .unmarshallYaml(DataElasticityManagementProcess.class, elasticityProcessesXML); ElasticStateSet elasticStateSet = null; try { elasticStateSet = JAXBUtils.unmarshal(elasticStateSetXML, ElasticStateSet.class); } catch (JAXBException ex) { Logger.getLogger(ElasticityProcessesStore.class.getName()).log(Level.SEVERE, null, ex); } ElasticDataAsset eda = new ElasticDataAsset(edaasName, elasticityProcess, elasticStateSet.getFinalElasticStateSet()); return eda; }
From source file:at.ac.tuwien.dsg.dataassetloader.store.MySqlDataAssetStore.java
public String copyDataAssetRepo(MonitoringSession monitoringSession, int dataAssetCounter) { System.out.println("Staring Copying Data ..."); InputStream inputStream = null; MySqlConnectionManager connectionManager = new MySqlConnectionManager(ip, port, db, user, pass); String sql = "Select * from DataAsset where daw_name='" + monitoringSession.getDataAssetID() + "' " + "and partitionID='" + dataAssetCounter + "'"; System.out.println("sql: " + sql); ResultSet rs = connectionManager.ExecuteQuery(sql); try {//from w w w .j a va 2 s . com while (rs.next()) { inputStream = rs.getBinaryStream("da"); StringWriter writer = new StringWriter(); String encoding = StandardCharsets.UTF_8.name(); IOUtils.copy(inputStream, writer, encoding); String daPartitionStr = writer.toString(); String name = monitoringSession.getEdaasName() + ";" + monitoringSession.getSessionID() + ";" + monitoringSession.getDataAssetID(); DataAsset dataAssetPartition = JAXBUtils.unmarshal(daPartitionStr, DataAsset.class); dataAssetPartition.setDataAssetID(name); insertDataPartitionRepo(dataAssetPartition); } rs.close(); } catch (Exception ex) { } return "1"; }