how to use scriptlet in iReport

1. create your scriptlet and compile it, sample code is listed below.

package demo;

import java.math.BigDecimal;
import java.util.Date;
import net.sf.jasperreports.engine.JRDefaultScriptlet;

public class scriptletFXTaxForm extends JRDefaultScriptlet  {
CommonFunction cf;
public scriptletFXTaxForm(){
cf = new CommonFunction(true);
cf.ConnectToDB();
}
public BigDecimal Acca1(String sAcc){
BigDecimal dRet ;
dRet = BigDecimal.ZERO;

return dRet;
}
public String methodName(){
return “scriptletFXTaxForm";
}
}

2. add you scriptlet to iReport classpath, don’t forget add all used lib or jar into iReport classpath ( if you lost one of them, you can’t work correctly )

3. In iReport , add demo.scriptletFXTaxForm to Scriptlet Class property.

in this demo case , your should add sqljdbc4.jar to iReport classpath

see also

http://blog.sacaluta.com/2007/07/jasperreports-scriptlet-example.html

http://blog.sacaluta.com/2005/10/using-jasperreports-scriptlet.html

Unfortunately, I still can’t use scriptlet in Netbeans plugin iReport.

Finding the highest value in several SQL Server columns

Finding the highest value in several SQL Server columns

You have a SQL Server table with n columns containing integers, floats, money, or dates, and it’s your task to return the maximum value contained on a row from these columns. You may even be required to do this for multiple rows at once, returning a record set.

The first supposition suggests that you may not know in advance which or how many columns to compare, but this may not always be true. It’s possible that you always know exactly which columns to compare and know that it’s unlikely that any new ones will be added. On the other hand, you may have to program defensively, anticipating that some new column(s) might be added. Writing a function that compares exactly n values would do the job, but how useful would that be elsewhere?

The Problem: Does SQL Server have anything like VB’s On Error GoTo?

Tip (SQL Server): Error Handling in a Stored Procedure

Tips and Tricks for: SQL Server
The Problem: Does SQL Server have anything like VB’s On Error GoTo?

To those familiar with Visual Basic, VB provides the option to use the ON ERROR GOTO … clause to catch practically any error and handle it in one’s program.

Does SQL Server 2000 have the analogous clause that will jump to a certain part of code in a stored procedure to handle errors?
Solution: Errors must be checked after every SQL statement of interest.

php下的MVC [Zend Framework] 教學

酷!學園 – php下的MVC [Zend Framework] 教學

Zend Framework是php裡頭其中一種Framework.在台灣跟香港都比較難找到關於Zend Framework的文章.反而CakePHP的文章就很多.所以今天我想分享一下我的心得.我現在的Project都是用Zend Framework來完成.Zend Framework提供大量的module給你使用.它還提供連接Google,Yahoo,Flickr,Amazon..etc Web Services的module.

Calling A Stored Procedure In Java With A Blob Field

Calling A Stored Procedure In Java With A Blob Field | franzone.com

Calling A Stored Procedure In Java With A Blob Field
Author : Jonathan Franzone
No Comments

Here is the situation. You are writing a program in Java. You need to access data in a Microsoft SQL Server via stored procedure and the data has an XML field. A what field? SQL Server 2005 introduces a new datatype for XML. It is essentially a blob field that you can perform XML operations on. For the Java program though, it doesn’t really care about that functionality and can just access it to write it out to a file (or process it inline).

java String.Format() 方法及参数说明

java String.Format() 方法及参数说明 – Java(J2EE J2ME J2SE)

JDK1.5中,String类新增了一个很有用的静态方法String.format():
format(Locale l, String format, Object… args) 使用指定的语言环境、格式字符串和参数返回一个格式化字符串。
format(String format, Object… args) 使用指定的格式字符串和参数返回一个格式化字符串。