scphantm Posted July 22, 2010 Share Posted July 22, 2010 the way my system works is i need to have a report that can run against about 100 or so identical databases. when the user logs in, jasperserver has to associate a specific data source to that user and when a report is run use that data source thats specific to the user for their reports. that way i can have one instance of jasperserver running several hundred user accounts. is that possible? Link to comment Share on other sites More sharing options...
ramnik Posted July 22, 2010 Share Posted July 22, 2010 You can try using the LoggedInUser Built In parameter in querystring of report .Ramnik KaurSenior QA Engineer Link to comment Share on other sites More sharing options...
scphantm Posted July 22, 2010 Author Share Posted July 22, 2010 im researching the custom datasource code thats distributed with the server. if i use the hibernate example, how exactly could i pass the name of the role that the user is a member of to the HibernateDataSourceService class? it looks like if i accomplish that then i can simply define all my databases in the application context file of my datasource and have the roles in jasperserver match. if i can somehow pass the data source the role name, i should have it right? Link to comment Share on other sites More sharing options...
scphantm Posted July 22, 2010 Author Share Posted July 22, 2010 im trying to get the custom datasource examples to deploy. when i restart the server i get class version errors on the new class files. what version of the JVM is this built with? im using jvm 6 for everything so i would imagine it should work Link to comment Share on other sites More sharing options...
scphantm Posted July 22, 2010 Author Share Posted July 22, 2010 got it. i see now its distributed with jre 5. switched it and all is well. now back to my normal problem, you think this approach with a custom data source is the way to go? Link to comment Share on other sites More sharing options...
madarapuv Posted July 23, 2010 Share Posted July 23, 2010 To achieve the solution you have to modify jasperreport.jar file.In each Report pass a parameter it should contain the information related to connection.example:JNDI_NAME JRJdbcQueryExecuter.java modify this class(you can find this file in jasperreport.jar/ net/sf/jasperreports/engine/query) Here is the code needs to be modified. public JRJdbcQueryExecuter(JRDataset dataset, Map parameters) { super(dataset, parameters); connection = (Connection ) getParameterValue(JRParameter.REPORT_CONNECTION); /*Custom Code Start*/ if(connection==null){ JRFillParameter JNDI_NAME = getParameter("JNDI_NAME");(get the parameter whatever you’re passing from report) Class clazz = JNDI_NAME.getValueClass(); Object JNDI_NAME_Value = JNDI_NAME.getValue(); Context ctx = null; DataSource ds=null; try{ initial = new InitialContext(); Context envContext = (Context)initial.lookup("java:/comp/env"); if(JNDI_NAME_Value!=null ) ds = (DataSource)envContext.lookup(JNDI_NAME_Value.toString()); connection=ds.getConnection(); System.out.println("Connection Object----------------------"+connection); } /*Custom Code End*/ catch(Exception e){ e.printStackTrace(); } finally{ try{ if(ctx != null){ ctx.close(); } } catch(Exception e) { e.printStackTrace(); } } } Replace this class file in jasperreports.jar and copy this jar in jasperserver-pro/WEB-INF/lib dir. Finally while creating the report in jasper server Please select data source none option. Venkat. 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