ジャスパーレポートは初めてです。SQL Server ストアド プロシージャを使用して 1 つのレポートを作成しました。レポートを Swing フレームから表示すると、次の例外が発生します。
Could not create the report java.lang.String cannot be cast to java.lang.Integer
SQL Server 2000 のストアド プロシージャの定義と同じデータ型でレポートのパラメータを定義しました。
以下は、ストアド プロシージャ呼び出しのパラメーターとクエリを示す .jrxml ファイルの一部です。
<parameter name="CatID" class="java.lang.String"/>
<parameter name="Start" class="java.lang.Integer"/>
<parameter name="Stop" class="java.lang.Integer"/>
<parameter name="GoldID" class="java.lang.String"/>
<parameter name="Percentage" class="java.lang.Float"/>
<parameter name="Karat" class="java.lang.Integer"/>
<parameter name="DiaGrade" class="java.lang.Integer"/>
<parameter name="StoneGrade" class="java.lang.Integer"/>
<queryString>
<![CDATA[{call PriceList($P{CatID},$P{Start} ,$P{Stop},$P{GoldID},$P{Karat},$P{StoneGrade} ,$P{DiaGrade},$P{Percentage} ) }]]>
</queryString>
<field name="Design" class="java.lang.String"/>
<field name="DesignP" class="java.lang.String"/>
<field name="Model" class="java.lang.String"/>
<field name="GoldCode" class="java.lang.String"/>
<field name="CatID" class="java.lang.String"/>
<field name="OrnID" class="java.lang.Integer"/>
<field name="StoneID" class="java.lang.String"/>
<field name="ProfitPer" class="java.math.BigDecimal"/>
<field name="PlatingChg" class="java.lang.Integer"/>
<field name="SetCode" class="java.lang.String"/>
<field name="CompCost" class="java.math.BigDecimal"/>
<field name="USRate" class="java.math.BigDecimal"/>
<field name="CCost" class="java.math.BigDecimal"/>
<field name="Karat" class="java.lang.Integer"/>
<field name="GoldIDConv" class="java.lang.String"/>
<field name="StoneGrade" class="java.lang.Integer"/>
<field name="DiaGrade" class="java.lang.Integer"/>
<field name="CompCost1" class="java.math.BigDecimal"/>
<field name="GCost" class="java.math.BigDecimal"/>
<field name="ACost" class="java.math.BigDecimal"/>
<field name="SCost" class="java.math.BigDecimal"/>
<field name="Cost" class="java.math.BigDecimal"/>
<field name="Percentage" class="java.math.BigDecimal"/>
<field name="Price" class="java.math.BigDecimal"/>
私のStored procの一部は次のとおりです
create PROCEDURE PriceList
@CatID char(1),
@Start int,
@Stop int,
@GoldID char(1),
@Karat tinyInt,
@StoneGrade tinyint,
@DiaGrade tinyInt,
@Percentage numeric(6,3)
AS
DECLARE @mGold varchar(4),
@TotStones int,
@StoneGradePrice int,
@CurrRate numeric(9,5)
Select @mGold = ''
Select @CurrRate = Rate From Currency Where Currency = 1
Select @TotStones = 0
Select @StoneGradePrice = 0
IF @GoldID='W'
SELECT @mGold='W'
IF @GoldID='N'
SELECT @mGold='WN'
IF @GoldID='P'
SELECT @mGold='PT'
IF @GoldID = 'Z'
Select @mGold = '(2T)'
IF @GoldID = 'Q'
Select @mGold = '(2P)'
SELECT Design=convert(varchar(20),Design+@mGold),
DesignP=Design,Model=dbo.GetModel(Design),GoldCode=@mGold,
CatID,
OrnID,
StoneID,
ProfitPer,
PlatingChg,
SetCode,
CompCost ,
USRate=@CurrRate,
CCost=CUS/@CurrRate
INTO #CTemp
FROM Charges a
WHERE a.CatID=@CatID
AND OrnID BETWEEN @Start AND @Stop
IF @GoldID='0'or @GoldID = 'Z' or @GoldID = 'T' or @GoldID = 'Q' or @GoldID = 'V'
SELECT a.CatID,
OrnID,Small=max(isnull(b.Small,0)), Medium=max(isnull(b.Medium,0)), Large=max(isnull(b.Large,0)),Karat=@Karat,GCost=SUM(GUS),KChainConv=max(KChainConv)
INTO #GTemp
FROM GoldCost a left outer join CatGoldPlatingChg b on a.catid = b.catid and b.GoldID = @GoldID
WHERE a.CatID=@CatID AND mKarat=@Karat
AND OrnID BETWEEN @Start AND @Stop
GROUP BY a.CatID,OrnID
SELECT a.*,
b.Karat,
GoldIDConv=@GoldID,
StoneGrade,
DiaGrade,
CompCost1=coalesce(CompCost *((100+KChainConv)/100),0),
GCost=coalesce(GCost,0) +( coalesce((case PlatingChg when 1 then Small when 2 then Medium else Large end),0)/@CurrRate) ,
ACost=coalesce(ACost,0),
SCost= coalesce(SCost,0),
Cost=coalesce(CCost,0)+ coalesce(ACost,0) + coalesce(GCost,0)+ (coalesce((case PlatingChg when 1 then Small when 2 then Medium else Large end),0)/@CurrRate) +coalesce(SCost,0) + coalesce(CompCost *((100+KChainConv)/100),0),
Percentage=@Percentage,
Price=(convert(numeric(10,0),ceiling((((
coalesce(CCost,0)+ coalesce(ACost,0) + coalesce(GCost,0) + (coalesce((case PlatingChg when 1 then Small when 2 then Medium else Large end),0)/@CurrRate) +coalesce(SCost,0)) * (100+ProfitPer))/100) + coalesce((CompCost) *((100+KChainConv)/100),0) ) * (100+@Percentage)/100))
FROM #CTemp a
LEFT JOIN tempdb.#GTemp b ON (a.CatID=b.CatID AND a.OrnID=b.OrnID )
LEFT JOIN tempdb.#ATemp d ON (a.CatID=d.CatID AND a.OrnID=d.OrnID )
LEFT JOIN tempdb.#STemp c ON (a.CatID=c.CatID AND a.OrnID=c.OrnID AND a.StoneID=c.StoneID)
WHERE b.GCOST IS NOT NULL AND c.SCOST IS NOT NULL
ORDER BY a.CatID,a.OrnID