maria1985 Posted July 28, 2010 Share Posted July 28, 2010 helloI created a custom datasourcethis is the codepackage com.emergya.esteve.tcerebral.web.util;import net.sf.jasperreports.engine.JRDataSource;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRField;public class SupervivencyDataSource implements JRDataSource{private Object[][] data ={{new Integer(1), new Float(100)},{new Integer(2), new Float(98.6)}};private int index = -1;public SupervivencyDataSource(){}public boolean next() throws JRException{index++;return (index < data.length);}public Object getFieldValue(JRField field) throws JRException{Object value = null;String fieldName = field.getName();if ("mounth".equals(fieldName)){value = data[index][0];}else if ("percent".equals(fieldName)){value = data[index][1];}return value;} }package com.emergya.esteve.tcerebral.web.util;import net.sf.jasperreports.engine.JRDataSource;public class SupervivencyDataSourceFactory {public static JRDataSource createDatasource(){return new SupervivencyDataSource();}} i tested in ireport and the connection was successfull and i created a report.but i want to secure the datasource by an authentication(user and password)can you help me ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now