@Test public void testAddViewPoint() throws Throwable { ViewPoint viewPoint = new ViewPoint(); viewPoint.setPointId(2); ClassPathResource res = new ClassPathResource("temp.jpg"); byte[] mockImg = FileCopyUtils.copyToByteArray(res.getFile()); viewPoint.setImgFile(mockImg); viewPoint.setDescription("测试景区介绍"); viewPointDao.addViewPoint(viewPoint); }
public void addViewPoint(final ViewPoint viewPoint) { String sql = " INSERT INTO t_view_point(point_id,space_id,point_name,ticket_price,img_file,description)" + " VALUES(?,?,?,?,?,?)"; jdbcTemplate.execute(sql, new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setInt(1, incre.nextIntValue()); ps.setInt(2, viewPoint.getSpaceId()); ps.setString(3, viewPoint.getPointName()); ps.setDouble(4, viewPoint.getTicketPrice()); lobCreator.setClobAsString(ps, 6, viewPoint.getDescription()); lobCreator.setBlobAsBytes(ps, 5, viewPoint.getImgFile()); } }); }
ViewPointDao { public void addViewPoint(final ViewPoint viewPoint) { String sql = " INSERT INTO t_view_point(point_id,space_id,point_name,ticket_price,img_file,description)" + " VALUES(?,?,?,?,?,?)"; jdbcTemplate.execute(sql, new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setInt(1, incre.nextIntValue()); ps.setInt(2, viewPoint.getSpaceId()); ps.setString(3, viewPoint.getPointName()); ps.setDouble(4, viewPoint.getTicketPrice()); lobCreator.setClobAsString(ps, 6, viewPoint.getDescription()); lobCreator.setBlobAsBytes(ps, 5, viewPoint.getImgFile()); } }); } }
ViewPointDao { public void addViewPoint(final ViewPoint viewPoint) { String sql = " INSERT INTO t_view_point(point_id,space_id,point_name,ticket_price,img_file,description)" + " VALUES(?,?,?,?,?,?)"; jdbcTemplate.execute(sql, new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setInt(1, incre.nextIntValue()); ps.setInt(2, viewPoint.getSpaceId()); ps.setString(3, viewPoint.getPointName()); ps.setDouble(4, viewPoint.getTicketPrice()); lobCreator.setClobAsString(ps, 6, viewPoint.getDescription()); lobCreator.setBlobAsBytes(ps, 5, viewPoint.getImgFile()); } }); }  }
ViewPointDao { public void addViewPoint(final ViewPoint viewPoint) { String sql = " INSERT INTO t_view_point(point_id,space_id,point_name,ticket_price,img_file,description)" + " VALUES(?,?,?,?,?,?)"; jdbcTemplate.execute(sql, new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setInt(1, incre.nextIntValue()); ps.setInt(2, viewPoint.getSpaceId()); ps.setString(3, viewPoint.getPointName()); ps.setDouble(4, viewPoint.getTicketPrice()); lobCreator.setClobAsString(ps, 6, viewPoint.getDescription()); lobCreator.setBlobAsBytes(ps, 5, viewPoint.getImgFile()); } }); }  void getNativeConn(); void addViewPoint(final ViewPoint viewPoint); List<ViewPoint> getImgFiles(final int spaceId); void getImgFile(final int pointId, final OutputStream os); double getReplyRate(int userId); int getSpaceViewPointNum(final int spaceId); int getUserTopicNum2(int userId); SqlRowSet getViewPointRowSet(int spaceId); JdbcTemplate getJdbcTemplate(); }
ViewPointDao { public void addViewPoint(final ViewPoint viewPoint) { String sql = " INSERT INTO t_view_point(point_id,space_id,point_name,ticket_price,img_file,description)" + " VALUES(?,?,?,?,?,?)"; jdbcTemplate.execute(sql, new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setInt(1, incre.nextIntValue()); ps.setInt(2, viewPoint.getSpaceId()); ps.setString(3, viewPoint.getPointName()); ps.setDouble(4, viewPoint.getTicketPrice()); lobCreator.setClobAsString(ps, 6, viewPoint.getDescription()); lobCreator.setBlobAsBytes(ps, 5, viewPoint.getImgFile()); } }); }  void getNativeConn(); void addViewPoint(final ViewPoint viewPoint); List<ViewPoint> getImgFiles(final int spaceId); void getImgFile(final int pointId, final OutputStream os); double getReplyRate(int userId); int getSpaceViewPointNum(final int spaceId); int getUserTopicNum2(int userId); SqlRowSet getViewPointRowSet(int spaceId); JdbcTemplate getJdbcTemplate();  }