Skip to content

Commit

Permalink
Fix 53303 Sybase JDBC test report failed to be executed or converted
Browse files Browse the repository at this point in the history
Description of issue:
The passed parameter bigdecimal scale is not matched the ODA driver.

Description of resolution:
Reset the bigdecimal scale use the ODA.parameterMetaData.getScale.
  • Loading branch information
pshi authored and mwu committed Sep 28, 2012
1 parent 04bd734 commit 8484e1b
Showing 1 changed file with 47 additions and 2 deletions.
Expand Up @@ -4355,7 +4355,8 @@ private void doSetBigDecimal( int paramIndex, BigDecimal decimal ) throws DataEx

try
{
getStatement().setBigDecimal( paramIndex, decimal );
getStatement( ).setBigDecimal( paramIndex,
getScaleValue( decimal, paramIndex ) );
}
catch( OdaException ex )
{
Expand All @@ -4377,7 +4378,8 @@ private void doSetBigDecimal( ParameterName paramName, BigDecimal decimal ) thro
String effectiveParamName = paramName.getEffectiveName();
try
{
getStatement().setBigDecimal( effectiveParamName, decimal );
getStatement( ).setBigDecimal( effectiveParamName,
getScaleValue( decimal, paramName ) );
}
catch( OdaException ex )
{
Expand All @@ -4396,6 +4398,49 @@ private void doSetBigDecimal( ParameterName paramName, BigDecimal decimal ) thro
}
}

/**
*
* check the passed bigDecimal scale, make sure the scale <= data base scale.
* @param value
* @param parameterId
* @return
*/
private BigDecimal getScaleValue( BigDecimal value, int parameterId )
{
int scale = 0;
try
{
scale = this.getParameterMetaData( parameterId ).getScale( );
if ( scale == 0 )
{
return value;
}
}
catch (Exception ignore)
{
return value;
}
return value.setScale( scale, BigDecimal.ROUND_HALF_UP );
}

private BigDecimal getScaleValue( BigDecimal value, ParameterName parameterName )
{
int scale = 0;
try
{
scale = this.getParameterMetaData( parameterName ).getScale( );
if ( scale == 0 )
{
return value;
}
}
catch (Exception ignore)
{
return value;
}
return value.setScale( scale, BigDecimal.ROUND_HALF_UP );
}

private void doSetDate( int paramIndex, Date date ) throws DataException
{
final String methodName = "doSetDate( int, Date )"; //$NON-NLS-1$
Expand Down

0 comments on commit 8484e1b

Please sign in to comment.