Jump to content

I need help please with java + xml


yael

Recommended Posts

Hi,

1)How can I set an Icone/Image to a pageHeader?

2)How can I creat dinamic queryString parameters, I'm using JasperReport

I mean something like this

Code:

public class Report {
public Report() {
// TODO Auto-generated constructor stub

try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"«»);
Connection conn = DriverManager.getConnection(
"jdbc:«»sqlserver://matarotsrv:1111;databaseName=qm6", "aa",
"aa"«»);

// load JasperDesign from XML and compile it into JasperReport
JasperDesign jasperDesign = JRXmlLoader.load("task1.jrxml"«»);
JasperReport jasperReport = JasperCompileManager
.compileReport(jasperDesign);

HashMap parameters = new HashMap();
if(ownerId!= 0){
parameters.put("owner_id", new Integer(ownerId));
}
if(!(ownerName.equals(null))){
parameters.put("owner_name", new String(ownerName));
})
JasperPrint jasperPrint = JasperFillManager.fillReport(
jasperReport, parameters, conn);
JasperViewer.viewReport(jasperPrint, true);

} catch (Exception e) {
e.printStackTrace();
}
}

Then, in the xml file - How can I connect to the WHERE statment only if this properties is full with data??

Code:
[code]
<parameter name="owner_id" class="java.lang.Integer" />
<parameter name="owner_name" class="java.lang.String" />
...
Where tasks.owner_id = $P{owner_id} AND tasks.owner_name = $P{owner_name}

Thanks,

Yael. ;)

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...