List of usage examples for java.sql Types NUMERIC
int NUMERIC
To view the source code for java.sql Types NUMERIC.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type NUMERIC
.
From source file:org.springframework.jdbc.support.JdbcUtils.java
/** * Check whether the given SQL type is numeric. * @param sqlType the SQL type to be checked * @return whether the type is numeric//from w w w .j a v a2 s .c om */ public static boolean isNumeric(int sqlType) { return Types.BIT == sqlType || Types.BIGINT == sqlType || Types.DECIMAL == sqlType || Types.DOUBLE == sqlType || Types.FLOAT == sqlType || Types.INTEGER == sqlType || Types.NUMERIC == sqlType || Types.REAL == sqlType || Types.SMALLINT == sqlType || Types.TINYINT == sqlType; }
From source file:om.edu.squ.squportal.portlet.dps.registration.dropw.db.DropWDBImpl.java
/** * // ww w . ja v a 2s. c o m * method name : setDropWCourseWithdrawProc * @param dropWDTO * @return * DropWDBImpl * return type : int * * purpose : * * Date : May 7, 2017 10:36:17 AM */ @Transactional private Map setDropWCourseWithdrawProc(DropWDTO dropWDTO) throws NotSuccessFulDBUpdate { Map resultProc = null; simpleJdbcCallDpsDropW.withProcedureName(Constants.CONST_PROC_DROPW_WITHDRAW_COURSE); simpleJdbcCallDpsDropW.withoutProcedureColumnMetaDataAccess(); simpleJdbcCallDpsDropW.useInParameterNames(Constants.CONST_PROC_COL_NAME_P_STDNO, Constants.CONST_PROC_COL_NAME_P_SECTCD, Constants.CONST_PROC_COL_NAME_P_SECTNO, Constants.CONST_PROC_COL_NAME_P_USER); simpleJdbcCallDpsDropW.declareParameters( new SqlParameter(Constants.CONST_PROC_COL_NAME_P_STDNO, Types.NUMERIC), new SqlParameter(Constants.CONST_PROC_COL_NAME_P_SECTCD, Types.NUMERIC), new SqlParameter(Constants.CONST_PROC_COL_NAME_P_SECTNO, Types.NUMERIC), new SqlParameter(Constants.CONST_PROC_COL_NAME_P_USER, Types.VARCHAR) ); Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put(Constants.CONST_PROC_COL_NAME_P_STDNO, dropWDTO.getStudentNo()); paramMap.put(Constants.CONST_PROC_COL_NAME_P_SECTCD, dropWDTO.getSectCode()); paramMap.put(Constants.CONST_PROC_COL_NAME_P_SECTNO, dropWDTO.getSectionNo()); paramMap.put(Constants.CONST_PROC_COL_NAME_P_USER, dropWDTO.getUserName()); try { resultProc = simpleJdbcCallDpsDropW.execute(paramMap); } catch (BadSqlGrammarException badGrException) { logger.error("Might be a grammatical issue in stored procedure"); throw new NotSuccessFulDBUpdate(badGrException.getMessage()); } catch (UncategorizedSQLException exception) { logger.error("Course drop not successful for student no : {}, course no {} . Details : {} - {}", dropWDTO.getStudentNo(), dropWDTO.getCourseNo(), exception.getSQLException().getErrorCode(), exception.getSQLException().getMessage()); throw new NotSuccessFulDBUpdate(exception.getMessage()); } return resultProc; }
From source file:org.jumpmind.db.model.Column.java
/** * {@inheritDoc}/*from w ww . j a v a2s . co m*/ */ public boolean equals(Object obj) { if (obj instanceof Column) { Column other = (Column) obj; EqualsBuilder comparator = new EqualsBuilder(); // Note that this compares case sensitive comparator.append(name, other.name); comparator.append(primaryKey, other.primaryKey); comparator.append(required, other.required); comparator.append(autoIncrement, other.autoIncrement); comparator.append(mappedTypeCode, other.mappedTypeCode); comparator.append(getParsedDefaultValue(), other.getParsedDefaultValue()); // comparing the size makes only sense for types where it is // relevant if ((mappedTypeCode == Types.NUMERIC) || (mappedTypeCode == Types.DECIMAL)) { comparator.append(size, other.size); comparator.append(scale, other.scale); } else if ((mappedTypeCode == Types.CHAR) || (mappedTypeCode == Types.VARCHAR) || (mappedTypeCode == Types.BINARY) || (mappedTypeCode == Types.VARBINARY)) { comparator.append(size, other.size); } return comparator.isEquals(); } else { return false; } }
From source file:org.jumpmind.symmetric.io.data.DbFill.java
private Object generateRandomValueForColumn(Column column) { Object objectValue = null;/*from w w w .j a v a2 s . com*/ int type = column.getMappedTypeCode(); if (column.isEnum()) { objectValue = column.getEnumValues()[new Random().nextInt(column.getEnumValues().length)]; } else if (column.isTimestampWithTimezone()) { objectValue = String.format("%s %s", FormatUtils.TIMESTAMP_FORMATTER.format(randomDate()), AppUtils.getTimezoneOffset()); } else if (type == Types.DATE) { objectValue = DateUtils.truncate(randomDate(), Calendar.DATE); } else if (type == Types.TIMESTAMP || type == Types.TIME) { objectValue = randomTimestamp(); } else if (type == Types.INTEGER || type == Types.BIGINT) { objectValue = randomInt(); } else if (type == Types.SMALLINT) { objectValue = randomSmallInt(column.getJdbcTypeName().toLowerCase().contains("unsigned")); } else if (type == Types.FLOAT) { objectValue = randomFloat(); } else if (type == Types.DOUBLE) { objectValue = randomDouble(); } else if (type == Types.TINYINT) { objectValue = randomTinyInt(); } else if (type == Types.NUMERIC || type == Types.DECIMAL || type == Types.REAL) { objectValue = randomBigDecimal(column.getSizeAsInt(), column.getScale()); } else if (type == Types.BOOLEAN || type == Types.BIT) { objectValue = randomBoolean(); } else if (type == Types.BLOB || type == Types.LONGVARBINARY || type == Types.BINARY || type == Types.VARBINARY || // SQLServer text type type == -10) { objectValue = randomBytes(); } else if (type == Types.ARRAY) { objectValue = null; } else if (type == Types.VARCHAR || type == Types.LONGVARCHAR || type == Types.CHAR || type == Types.CLOB) { int size = 0; // Assume if the size is 0 there is no max size configured. if (column.getSizeAsInt() != 0) { size = column.getSizeAsInt() > 50 ? 50 : column.getSizeAsInt(); } else { // No max length so default to 50 size = 50; } objectValue = randomString(size); } else if (type == Types.OTHER) { if ("UUID".equalsIgnoreCase(column.getJdbcTypeName())) { objectValue = randomUUID(); } } return objectValue; }
From source file:com.cloudera.sqoop.manager.SqlManager.java
/** * Resolve a database-specific type to the Java type that should contain it. * @param sqlType//from www . j av a2 s . c o m * @return the name of a Java type to hold the sql datatype, or null if none. */ public String toJavaType(int sqlType) { // Mappings taken from: // http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html if (sqlType == Types.INTEGER) { return "Integer"; } else if (sqlType == Types.VARCHAR) { return "String"; } else if (sqlType == Types.CHAR) { return "String"; } else if (sqlType == Types.LONGVARCHAR) { return "String"; } else if (sqlType == Types.NUMERIC) { return "java.math.BigDecimal"; } else if (sqlType == Types.DECIMAL) { return "java.math.BigDecimal"; } else if (sqlType == Types.BIT) { return "Boolean"; } else if (sqlType == Types.BOOLEAN) { return "Boolean"; } else if (sqlType == Types.TINYINT) { return "Integer"; } else if (sqlType == Types.SMALLINT) { return "Integer"; } else if (sqlType == Types.BIGINT) { return "Long"; } else if (sqlType == Types.REAL) { return "Float"; } else if (sqlType == Types.FLOAT) { return "Double"; } else if (sqlType == Types.DOUBLE) { return "Double"; } else if (sqlType == Types.DATE) { return "java.sql.Date"; } else if (sqlType == Types.TIME) { return "java.sql.Time"; } else if (sqlType == Types.TIMESTAMP) { return "java.sql.Timestamp"; } else if (sqlType == Types.BINARY || sqlType == Types.VARBINARY) { return BytesWritable.class.getName(); } else if (sqlType == Types.CLOB) { return ClobRef.class.getName(); } else if (sqlType == Types.BLOB || sqlType == Types.LONGVARBINARY) { return BlobRef.class.getName(); } else { // TODO(aaron): Support DISTINCT, ARRAY, STRUCT, REF, JAVA_OBJECT. // Return null indicating database-specific manager should return a // java data type if it can find one for any nonstandard type. return null; } }
From source file:org.jumpmind.symmetric.service.impl.FileSyncService.java
public void save(ISqlTransaction sqlTransaction, FileSnapshot snapshot) { snapshot.setLastUpdateTime(new Date()); if (0 == sqlTransaction.prepareAndExecute(getSql("updateFileSnapshotSql"), new Object[] { snapshot.getLastEventType().getCode(), snapshot.getCrc32Checksum(), snapshot.getFileSize(), snapshot.getFileModifiedTime(), snapshot.getLastUpdateTime(), snapshot.getLastUpdateBy(), snapshot.getChannelId(), snapshot.getReloadChannelId(), snapshot.getTriggerId(), snapshot.getRouterId(), snapshot.getRelativeDir(), snapshot.getFileName() }, new int[] { Types.VARCHAR, Types.NUMERIC, Types.NUMERIC, Types.NUMERIC, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR })) { snapshot.setCreateTime(snapshot.getLastUpdateTime()); sqlTransaction.prepareAndExecute(getSql("insertFileSnapshotSql"), new Object[] { snapshot.getLastEventType().getCode(), snapshot.getCrc32Checksum(), snapshot.getFileSize(), snapshot.getFileModifiedTime(), snapshot.getCreateTime(), snapshot.getLastUpdateTime(), snapshot.getLastUpdateBy(), snapshot.getChannelId(), snapshot.getReloadChannelId(), snapshot.getTriggerId(), snapshot.getRouterId(), snapshot.getRelativeDir(), snapshot.getFileName() }, new int[] { Types.VARCHAR, Types.NUMERIC, Types.NUMERIC, Types.NUMERIC, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }); }/*from w ww . ja v a 2 s .c o m*/ // now that we have captured an update, delete the row for cleanup if (snapshot.getLastEventType() == LastEventType.DELETE) { sqlTransaction.prepareAndExecute(getSql("deleteFileSnapshotSql"), new Object[] { snapshot.getTriggerId(), snapshot.getRouterId(), snapshot.getRelativeDir(), snapshot.getFileName() }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }); } }
From source file:com.streamsets.pipeline.lib.jdbc.multithread.TableContextUtil.java
public static String getPartitionSizeValidationError(int colType, String column, String partitionSize) { switch (colType) { case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: try {/*from www . j a va 2 s. c om*/ int intVal = Integer.parseInt(partitionSize); if (intVal <= 0) { return createPartitionSizeValidationError(column, partitionSize, colType, GENERIC_PARTITION_SIZE_GT_ZERO_MSG); } } catch (NumberFormatException e) { return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage()); } break; case Types.BIGINT: // TIME, DATE, and TIMESTAMP are represented as long (epoch) case Types.TIME: case Types.DATE: case Types.TIMESTAMP: try { long longVal = Long.parseLong(partitionSize); if (longVal <= 0) { return createPartitionSizeValidationError(column, partitionSize, colType, GENERIC_PARTITION_SIZE_GT_ZERO_MSG); } } catch (NumberFormatException e) { return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage()); } break; case Types.FLOAT: case Types.REAL: try { float floatVal = Float.parseFloat(partitionSize); if (floatVal <= 0) { return createPartitionSizeValidationError(column, partitionSize, colType, GENERIC_PARTITION_SIZE_GT_ZERO_MSG); } } catch (NumberFormatException e) { return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage()); } break; case Types.DOUBLE: try { double doubleVal = Double.parseDouble(partitionSize); if (doubleVal <= 0) { return createPartitionSizeValidationError(column, partitionSize, colType, GENERIC_PARTITION_SIZE_GT_ZERO_MSG); } } catch (NumberFormatException e) { return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage()); } break; case Types.NUMERIC: case Types.DECIMAL: try { BigDecimal decimalValue = new BigDecimal(partitionSize); if (decimalValue.signum() < 1) { return createPartitionSizeValidationError(column, partitionSize, colType, GENERIC_PARTITION_SIZE_GT_ZERO_MSG); } } catch (NumberFormatException e) { return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage()); } break; } return null; }
From source file:org.apache.ode.bpel.extvar.jdbc.JdbcExternalVariableModule.java
private Object downcastValue(Object value, int dataType) { if (value == null) { return null; }// ww w. j ava 2s . c om // Try down casting the value as per its column type. try { // Some JDBC 4.0 types have been ignored to avoid compilation errors switch (dataType) { case Types.ARRAY: break; case Types.BIGINT: if (!(value instanceof BigInteger)) { value = new BigDecimal(value.toString()).longValue(); } break; case Types.BINARY: break; case Types.BIT: if (!(value instanceof Boolean)) { value = new Boolean(value.toString()); } break; case Types.BLOB: break; case Types.BOOLEAN: if (!(value instanceof Boolean)) { value = new Boolean(value.toString()); } break; case Types.CHAR: break; case Types.CLOB: break; case Types.DATALINK: break; case Types.DATE: break; case Types.DECIMAL: //ODE-872: Oracle 9g and 10g has problems with BigDecimal on Java1.5 value = new BigDecimal(new BigDecimal(value.toString()).toPlainString()); break; case Types.DISTINCT: break; case Types.DOUBLE: if (!(value instanceof Double)) { value = Double.valueOf(value.toString()).doubleValue(); } break; case Types.FLOAT: if (!(value instanceof Float)) { value = Float.valueOf(value.toString()).floatValue(); } break; case Types.INTEGER: if (!(value instanceof Integer)) { value = Double.valueOf(value.toString()).intValue(); } break; case Types.JAVA_OBJECT: break; // case Types.LONGNVARCHAR: // break; case Types.LONGVARBINARY: break; case Types.LONGVARCHAR: break; // case Types.NCHAR: // break; // case Types.NCLOB: // break; case Types.NUMERIC: //ODE-872: Oracle 9g and 10g has problems with BigDecimal on Java1.5 value = new BigDecimal(new BigDecimal(value.toString()).toPlainString()); break; // case Types.NVARCHAR: // break; case Types.OTHER: break; case Types.REAL: if (!(value instanceof Double)) { value = Float.valueOf(value.toString()).floatValue(); } break; case Types.REF: break; // case Types.ROWID: // break; case Types.SMALLINT: if (!(value instanceof Short)) { value = new Short(value.toString()).shortValue(); } break; // case Types.SQLXML: // break; case Types.STRUCT: break; case Types.TIME: break; case Types.TIMESTAMP: break; case Types.TINYINT: if (!(value instanceof Short)) { value = new Short(value.toString()).shortValue(); } break; case Types.VARBINARY: break; case Types.VARCHAR: break; default: break; } } catch (Exception e) { // couldn't cast... let's just use original value object } return value; }
From source file:architecture.ee.web.community.page.dao.jdbc.JdbcPageDao.java
public void update(Page page, boolean isNewVersion) { int prevVersionId = page.getVersionId(); Date now = Calendar.getInstance().getTime(); if (isNewVersion) { int maxVersionId = getExtendedJdbcTemplate().queryForObject( getBoundSql("ARCHITECTURE_COMMUNITY.SELECT_MAX_PAGE_VERSION_NUMBER").getSql(), Integer.class, new SqlParameterValue(Types.NUMERIC, page.getPageId())); page.setVersionId(maxVersionId + 1); }/* w ww. j av a 2 s . co m*/ page.setModifiedDate(now); // update page ... getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_COMMUNITY.UPDATE_PAGE").getSql(), new SqlParameterValue(Types.NUMERIC, page.getPageId()), new SqlParameterValue(Types.NUMERIC, page.getObjectType()), new SqlParameterValue(Types.NUMERIC, page.getObjectId()), new SqlParameterValue(Types.VARCHAR, page.getName()), new SqlParameterValue(Types.NUMERIC, page.getVersionId()), new SqlParameterValue(Types.NUMERIC, page.getUser().getUserId()), new SqlParameterValue(Types.TIMESTAMP, page.getModifiedDate()), new SqlParameterValue(Types.NUMERIC, page.getPageId())); updateProperties(page); if (isNewVersion) { insertPageVersion(page); insertPageBody(page); } else { updatePageVersion(page, prevVersionId); updatePageBody(page, prevVersionId); } }
From source file:org.pentaho.platform.plugin.action.jfreereport.JFreeReportGeneratorComponent.java
@SuppressWarnings("deprecation") public String process() { // CREATE report-spec.xml // USE passed in jfreeReportTemplate as "include" -- stuff in // report-spec // GENERATE JFreeReport from report-spec using code already written in // DesignerUtility ////from w w w .j a v a2 s . c o m ByteArrayOutputStream outputStream = null; try { outputStream = new ByteArrayOutputStream(); } catch (Exception e) { getLogger().error(e); } ReportSpec reportSpec = new ReportSpec(); reportSpec.setReportName(reportName); reportSpec.setHorizontalOffset(horizontalOffset); reportSpec.setIncludeSrc(getPath()); reportSpec.setQuery("no query"); //$NON-NLS-1$ reportSpec.setReportSpecChoice(new ReportSpecChoice()); reportSpec.getReportSpecChoice().setJndiSource("SampleData"); //$NON-NLS-1$ reportSpec.setCalculateGrandTotals(createGrandTotals); reportSpec.setTopMargin(10); reportSpec.setBottomMargin(10); reportSpec.setLeftMargin(10); reportSpec.setRightMargin(10); reportSpec.setUseRowBanding(createRowBanding); reportSpec.setColumnHeaderGap(columnHeaderGap); if (rowBandingColor != null) { reportSpec.setRowBandingColor(rowBandingColor); } if (columnHeaderBackgroundColor != null) { reportSpec.setColumnHeaderBackgroundColor(columnHeaderBackgroundColor); } if (columnHeaderForegroundColor != null) { reportSpec.setColumnHeaderFontColor(columnHeaderForegroundColor); } if (columnHeaderFontFace != null) { reportSpec.setColumnHeaderFontName(columnHeaderFontFace); } if (columnHeaderFontSize != null) { reportSpec.setColumnHeaderFontSize(Integer.parseInt(columnHeaderFontSize)); } reportSpec.setOrientation(orientation); Object[] colHeaders = resultSet.getMetaData().getColumnHeaders()[0]; int totalWidth = reportSpec.getLeftMargin() + reportSpec.getRightMargin(); List groupsList = new LinkedList(); List details = new LinkedList(); // leading spacer if (spacerWidth > 0) { Field spacer = new Field(); spacer.setName(""); //$NON-NLS-1$ spacer.setDisplayName(""); //$NON-NLS-1$ spacer.setType(Types.VARCHAR); spacer.setFormat(""); //$NON-NLS-1$ spacer.setHorizontalAlignment("right"); //$NON-NLS-1$ spacer.setVerticalAlignment("middle"); //$NON-NLS-1$ spacer.setWidth(new BigDecimal(spacerWidth)); spacer.setWidthLocked(true); totalWidth += spacerWidth; spacer.setExpression("none"); //$NON-NLS-1$ spacer.setIsWidthPercent(false); spacer.setIsDetail(true); reportSpec.addField(spacer); } for (int i = 0; i < colHeaders.length; i++) { // System.out.println("header [" + i + "] = " + colHeaders[i]); Class typeClass = null; for (int j = 0; j < resultSet.getRowCount(); j++) { Object value = resultSet.getValueAt(j, i); if ((value != null) && !value.toString().equals("")) { //$NON-NLS-1$ typeClass = value.getClass(); } } String columnName = colHeaders[i].toString(); Field f = new Field(); f.setName(columnName); f.setNullString(getNullString()); if (isGroup(columnName)) { f.setDisplayName(getGroupLabel(columnName, i)); } else if (i < displayNames.length) { f.setDisplayName(displayNames[i]); } else { f.setDisplayName(columnName); } f.setIsWidthPercent(false); f.setWidth(new BigDecimal(getWidth(columnName))); f.setWidthLocked(true); f.setIsDetail(!isGroup(columnName)); if (f.getIsDetail()) { details.add(f); } else { groupsList.add(f); } f.setBackgroundColor("#FFFFFF"); //$NON-NLS-1$ f.setType(getType(typeClass)); if ((itemHides == null) || (itemHides.length == 0)) { f.setUseItemHide(getType(typeClass) == Types.NUMERIC ? false : true); } else { f.setUseItemHide(useItemHide(columnName)); } f.setVerticalAlignment("middle"); //$NON-NLS-1$ f.setFormat(getColumnFormat(columnName)); String alignment = getColumnAlignment(columnName); if (alignment != null) { f.setHorizontalAlignment(alignment); } else { if (f.getIsDetail() && (f.getType() == Types.NUMERIC)) { f.setHorizontalAlignment("right"); //$NON-NLS-1$ } } if (f.getIsDetail() && (f.getType() == Types.NUMERIC)) { f.setExpression("sum"); //$NON-NLS-1$ } else { f.setExpression("none"); //$NON-NLS-1$ } f.setCalculateGroupTotals(createSubTotals); reportSpec.addField(f); if ((spacerWidth > 0) && f.getIsDetail()) { // spacer Field spacer = new Field(); spacer.setName(""); //$NON-NLS-1$ spacer.setDisplayName(""); //$NON-NLS-1$ spacer.setType(Types.VARCHAR); spacer.setFormat(""); //$NON-NLS-1$ spacer.setHorizontalAlignment("right"); //$NON-NLS-1$ spacer.setVerticalAlignment("middle"); //$NON-NLS-1$ spacer.setWidth(new BigDecimal(spacerWidth)); spacer.setWidthLocked(true); totalWidth += spacerWidth; spacer.setExpression("none"); //$NON-NLS-1$ spacer.setIsWidthPercent(false); spacer.setIsDetail(true); reportSpec.addField(spacer); } } for (int i = 0; i < details.size(); i++) { Field f = (Field) details.get(i); totalWidth += f.getWidth().intValue(); } if (createTotalColumn) { Field f = new Field(); f.setName("TOTAL_COLUMN"); //$NON-NLS-1$ f.setDisplayName(totalColumnName); f.setType(Types.NUMERIC); f.setFormat(totalColumnFormat); f.setHorizontalAlignment("right"); //$NON-NLS-1$ f.setVerticalAlignment("middle"); //$NON-NLS-1$ f.setWidth(new BigDecimal(totalColumnWidth)); f.setWidthLocked(true); f.setExpression("sum"); //$NON-NLS-1$ f.setIsWidthPercent(false); f.setIsDetail(true); reportSpec.addField(f); totalWidth += totalColumnWidth; if (spacerWidth > 0) { // spacer Field spacer = new Field(); spacer.setName(""); //$NON-NLS-1$ spacer.setDisplayName(""); //$NON-NLS-1$ spacer.setType(Types.VARCHAR); spacer.setFormat(""); //$NON-NLS-1$ spacer.setHorizontalAlignment("right"); //$NON-NLS-1$ spacer.setVerticalAlignment("middle"); //$NON-NLS-1$ spacer.setWidth(new BigDecimal(spacerWidth)); spacer.setWidthLocked(true); totalWidth += spacerWidth; spacer.setExpression("none"); //$NON-NLS-1$ spacer.setIsWidthPercent(false); spacer.setIsDetail(true); reportSpec.addField(spacer); } } try { reportSpec.setUseCustomPageFormat(true); int width = 612; int height = 792; if (orientation.equalsIgnoreCase("landscape")) { //$NON-NLS-1$ width = height; height = 612; } // w totalWidth // - = ------------ // h scaledHeight int scaledHeight = (height * totalWidth) / width; if (orientation.equalsIgnoreCase("landscape")) { //$NON-NLS-1$ reportSpec.setCustomPageFormatHeight(totalWidth); reportSpec.setCustomPageFormatWidth(scaledHeight); ReportGenerationUtility.createJFreeReportXML(reportSpec, outputStream, scaledHeight, totalWidth, createTotalColumn, totalColumnName, totalColumnWidth, spacerWidth); } else { reportSpec.setCustomPageFormatHeight(scaledHeight); reportSpec.setCustomPageFormatWidth(totalWidth); ReportGenerationUtility.createJFreeReportXML(reportSpec, outputStream, totalWidth, scaledHeight, createTotalColumn, totalColumnName, totalColumnWidth, spacerWidth); } } catch (Exception e) { //ignore } return new String(outputStream.toByteArray()); }