List of usage examples for org.springframework.jdbc.core.support SqlLobValue SqlLobValue
public SqlLobValue(Reader reader, int length, LobHandler lobHandler)
From source file:org.sakuli.services.receiver.database.dao.impl.DaoTestCaseImpl.java
@Override public void saveTestCaseResult(final TestCase testCase) { logger.info("Save results for test case \"" + testCase.getId() + "\""); //create a map for the sql parameters MapSqlParameterSource tcParameters = new MapSqlParameterSource(); tcParameters.addValue("sahi_suites_id", testSuite.getDbPrimaryKey()); tcParameters.addValue("caseID", testCase.getId()); tcParameters.addValue("result", testCase.getState().getErrorCode()); tcParameters.addValue("result_desc", testCase.getState()); tcParameters.addValue("name", testCase.getName()); tcParameters.addValue("guid", testSuite.getGuid()); tcParameters.addValue("start", testCase.getStartDateAsUnixTimestamp()); tcParameters.addValue("stop", testCase.getStopDateAsUnixTimestamp()); tcParameters.addValue("warning", testCase.getWarningTime()); tcParameters.addValue("critical", testCase.getCriticalTime()); tcParameters.addValue("browser", testSuite.getBrowserInfo()); tcParameters.addValue("lastpage", testCase.getLastURL()); //try to save the screenshot try {//from www . j a v a2 s . c o m if (testCase.getScreenShotPath() != null) { final InputStream blobIs = Files.newInputStream(testCase.getScreenShotPath()); final int length = (int) testCase.getScreenShotPath().toFile().length(); tcParameters.addValue("screenshot", new SqlLobValue(blobIs, length, lobHandler), Types.BLOB); } } catch (IOException e) { throw new RuntimeException(e); } tcParameters.addValue("duration", testCase.getDuration()); tcParameters.addValue("msg", testCase.getExceptionMessages()); //generate the sql-statement SimpleJdbcInsert insertTCResults = new SimpleJdbcInsert(getDataSource()).withTableName("sahi_cases") .usingGeneratedKeyColumns("id"); logger.info( "write the following values to 'sahi_cases': " + tcParameters.getValues() + " => now execute ...."); int dbPrimaryKey = insertTCResults.executeAndReturnKey(tcParameters).intValue(); logger.info("test case '" + testCase.getId() + "' has been written to 'sahi_cases' with primaryKey=" + dbPrimaryKey); testCase.setDbPrimaryKey(dbPrimaryKey); }
From source file:architecture.ee.jdbc.sqlquery.SqlQueryHelper.java
public SqlQueryHelper lob(InputStream stream, int length) { SqlLobValue value = new SqlLobValue(stream, length, lobHandler); values.add(value);/*from ww w .java2 s.c o m*/ return this; }
From source file:architecture.ee.jdbc.sqlquery.SqlQueryHelper.java
public SqlQueryHelper lob(Reader reader, int length) { SqlLobValue value = new SqlLobValue(reader, length, lobHandler); values.add(value);//from w ww. java 2 s . co m return this; }
From source file:org.sakuli.services.forwarder.database.dao.impl.DaoTestCaseImpl.java
/** * Determine the first available screenshot inside of the testcase and respectively in the assigned steps. * For Details of the transformation, see {@link org.springframework.jdbc.support.lob.LobHandler}. * * @return a {@link SqlLobValue}/*from w w w. j a v a 2 s. c om*/ */ protected SqlLobValue getScreenshotAsSqlLobValue(TestCase testCase) { try { Path screenShotPath = testCase.getScreenShotPath(); if (screenShotPath == null) { //get first step exception for (TestCaseStep step : testCase.getStepsAsSortedSet()) { if (step.getScreenShotPath() != null) { screenShotPath = step.getScreenShotPath(); break; } } } if (screenShotPath != null) { final InputStream blobIs = Files.newInputStream(screenShotPath); final int length = (int) screenShotPath.toFile().length(); return new SqlLobValue(blobIs, length, lobHandler); } return null; } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.sr.model.dao.IMahasiswaDAOImpl.java
@Override public boolean insertBiodata(Mahasiswa mhs, AkademikSR aka, FileItem foto, List<Prestasi> prestasi) { try {//from ww w .j ava 2 s . c o m LobHandler lobHandler = new DefaultLobHandler(); getJdbcTemplate().update(INSERT_BIODATA, new Object[] { mhs.getNamaMhs(), mhs.getTempat_lahir(), mhs.getTanggal_lahir(), mhs.getAgama(), mhs.getKelamin(), mhs.getAlamat_asal(), mhs.getKab_kota_asal(), mhs.getProv_asal(), mhs.getNo_hp_mhs(), mhs.getNama_ayah(), mhs.getNama_ibu(), mhs.getPendidikan_ayah(), mhs.getPendidikan_ibu(), mhs.getPekerjaan_ayah(), mhs.getPekerjaan_ibu(), mhs.getPendapatan_ortu(), mhs.getNo_tel_ortu(), mhs.getNo_hp_ortu(), mhs.getAlamat_keluarga(), mhs.getNo_tel_keluarga(), mhs.getNo_hp_keluarga(), new SqlLobValue(foto.getInputStream(), (int) foto.getSize(), lobHandler), mhs.getNim() }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.NUMERIC, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.VARCHAR }); getJdbcTemplate().update(INSERT_AKADEMIK, new Object[] { aka.getProdi(), aka.getIpk_masuk(), aka.getSemester(), aka.getRapor_smu(), aka.getJurusan(), aka.getFakultas(), aka.getNim() }, new int[] { Types.VARCHAR, Types.DECIMAL, Types.NUMERIC, Types.DECIMAL, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }); for (Prestasi pres : prestasi) { getJdbcTemplate().update(INSERT_PRESTASI, new Object[] { pres.getNo_sertifikat(), pres.getNim(), pres.getNama_prestasi(), pres.getJenis_prestasi() }); } return true; } catch (DataAccessException da) { System.out.println("DataAccessException" + da.getMessage()); } catch (FileNotFoundException ex) { System.out.println("FileNotFoundException " + ex.getMessage()); } catch (IOException ex) { System.out.println(ex.getMessage()); } return false; }
From source file:org.sakuli.services.receiver.database.dao.impl.DaoTestSuiteImpl.java
private MapSqlParameterSource getCompleteParameters() { MapSqlParameterSource tcParameters = getInitialDataParameters(); tcParameters.addValues(getGuidParameter().getValues()); tcParameters.addValue("stop", testSuite.getStopDateAsUnixTimestamp()); tcParameters.addValue("warning", testSuite.getWarningTime()); tcParameters.addValue("critical", testSuite.getCriticalTime()); tcParameters.addValue("duration", testSuite.getDuration()); //try to save the screenshot try {/* w ww . j a v a 2 s . c o m*/ if (testSuite.getScreenShotPath() != null) { final InputStream blobIs = Files.newInputStream(testSuite.getScreenShotPath()); final int length = (int) testSuite.getScreenShotPath().toFile().length(); tcParameters.addValue("screenshot", new SqlLobValue(blobIs, length, lobHandler), Types.BLOB); } } catch (IOException e) { throw new RuntimeException(e); } tcParameters.addValue("msg", testSuite.getExceptionMessages()); return tcParameters; }
From source file:org.sakuli.services.forwarder.database.dao.impl.DaoTestSuiteImpl.java
private MapSqlParameterSource getCompleteParameters() { MapSqlParameterSource tcParameters = getInitialDataParameters(); tcParameters.addValues(getGuidParameter().getValues()); tcParameters.addValue("stop", testSuite.getStopDateAsUnixTimestamp()); int warningTime = testSuite.getWarningTime(); tcParameters.addValue("warning", (warningTime != 0) ? warningTime : null); int criticalTime = testSuite.getCriticalTime(); tcParameters.addValue("critical", (criticalTime != 0) ? criticalTime : null); tcParameters.addValue("duration", testSuite.getDuration()); //try to save the screenshot try {/* ww w . j av a 2s . c o m*/ if (testSuite.getScreenShotPath() != null) { final InputStream blobIs = Files.newInputStream(testSuite.getScreenShotPath()); final int length = (int) testSuite.getScreenShotPath().toFile().length(); tcParameters.addValue("screenshot", new SqlLobValue(blobIs, length, lobHandler), Types.BLOB); } } catch (IOException e) { throw new RuntimeException(e); } tcParameters.addValue("msg", testSuite.getExceptionMessages()); return tcParameters; }
From source file:architecture.ee.web.logo.dao.jdbc.JdbcLogoImageDao.java
protected void updateImageImputStream(LogoImage logoImage, InputStream inputStream) { getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_WEB.DELETE_LOGO_IMAGE_DATA_BY_ID").getSql(), new SqlParameterValue(Types.NUMERIC, logoImage.getLogoId())); if (getExtendedJdbcTemplate().getDatabaseType() == DatabaseType.oracle) { getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_WEB.INSERT_EMPTY_LOGO_IMAGE_DATA").getSql(), new SqlParameterValue(Types.NUMERIC, logoImage.getLogoId())); getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_WEB.UPDATE_LOGO_IMAGE_DATA").getSql(), new Object[] { new SqlLobValue(inputStream, logoImage.getImageSize(), getLobHandler()), logoImage.getLogoId() }, new int[] { Types.BLOB, Types.NUMERIC }); } else {//from w ww. jav a 2 s. c om getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_WEB.INSERT_LOGO_IMAGE_DATA").getSql(), new SqlParameterValue(Types.NUMERIC, logoImage.getLogoId()), new SqlParameterValue(Types.BLOB, new SqlLobValue(inputStream, logoImage.getImageSize(), getLobHandler()))); } }
From source file:architecture.ee.web.community.profile.dao.jdbc.JdbcProfileDao.java
protected void updateProfileImageImputStream(ProfileImage image, InputStream inputStream) { getExtendedJdbcTemplate().update(/*from w w w . ja v a 2 s .c o m*/ getBoundSql("ARCHITECTURE_COMMUNITY.DELETE_PROFILE_IMAGE_DATA_BY_ID").getSql(), new SqlParameterValue(Types.NUMERIC, image.getProfileImageId())); if (getExtendedJdbcTemplate().getDatabaseType() == DatabaseType.oracle) { getExtendedJdbcTemplate().update( getBoundSql("ARCHITECTURE_COMMUNITY.INSERT_EMPTY_PROFILE_IMAGE_DATA").getSql(), new SqlParameterValue(Types.NUMERIC, image.getProfileImageId())); getExtendedJdbcTemplate().update( getBoundSql("ARCHITECTURE_COMMUNITY.UPDATE_PROFILE_IMAGE_DATA").getSql(), new Object[] { new SqlLobValue(inputStream, image.getImageSize(), getLobHandler()), image.getProfileImageId() }, new int[] { Types.BLOB, Types.NUMERIC }); } else { getExtendedJdbcTemplate().update( getBoundSql("ARCHITECTURE_COMMUNITY.INSERT_PROFILE_IMAGE_DATA").getSql(), new SqlParameterValue(Types.NUMERIC, image.getProfileImageId()), new SqlParameterValue( Types.BLOB, new SqlLobValue(inputStream, image.getImageSize(), getLobHandler()))); } }