Hitachi Vantara Pentaho Community Forums
Results 1 to 9 of 9

Thread: Use a variable for Database Name

  1. #1
    Join Date
    Apr 2016
    Posts
    2

    Default Use a variable for Database Name

    hi,
    is it possible to use a variable to set database name in the connection, I tried this but it does not work

    Name:  pentaho1.jpg
Views: 116
Size:  21.8 KB
    Name:  pentaho2.png
Views: 104
Size:  6.0 KB


    anyone has any idea to solve this problem?

  2. #2
    Join Date
    Mar 2016
    Posts
    3

    Default

    Hard to see in the screenshot, but you have to use the curly brackets {} around the parameter name.

    rgds

  3. #3
    Join Date
    Apr 2016
    Posts
    2

    Default

    Hi, I used curly brackets {} but I get this exception
    If you see the exception complains that the database with name ${DatabaseName} does not exist, it looks like to me that the parameter name has not been replaced by the actual value

    17:21:59,575 WARN [org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLDataFactoryCore] (http-executor-threads - 2) Unable to compute referenced fields for query 'Query 1':: org.pentaho.reporting.engine.classic.core.ReportDataFactoryException: Unable to perform cache preparation
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.getReferencedFields(SimpleSQLReportDataFactory.java:230) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLReportDataFactory.getReferencedFields(SQLReportDataFactory.java:153) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLDataFactoryCore.getReferencedFields(SQLDataFactoryCore.java:59) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.metadata.DefaultDataFactoryMetaData.getReferencedFields(DefaultDataFactoryMetaData.java:88) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.CompoundDataFactoryCore.getReferencedFields(CompoundDataFactoryCore.java:39) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.sorting.SortingDataFactoryCore.getReferencedFields(SortingDataFactoryCore.java:34) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.metadata.DefaultDataFactoryMetaData.getReferencedFields(DefaultDataFactoryMetaData.java:88) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.cache.CachingDataFactory.createCacheKey(CachingDataFactory.java:362) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.cache.CachingDataFactory.queryStatic(CachingDataFactory.java:135) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.CompoundDataFactory.queryStaticInternal(CompoundDataFactory.java:168) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.CompoundDataFactory.queryStatic(CompoundDataFactory.java:154) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.CompoundDataFactory.queryData(CompoundDataFactory.java:67) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController.performQueryData(DefaultFlowController.java:248) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController.performQuery(DefaultFlowController.java:186) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.states.process.ProcessState.initializeForMasterReport(ProcessState.java:317) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.prepareReportProcessing(AbstractReportProcessor.java:425) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.processReport(AbstractReportProcessor.java:1415) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlReportUtil.createStreamHTML(HtmlReportUtil.java:103) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at app.angularjs.ServiceWrapper.printDownloadFilePentaho(ServiceWrapper.java:561) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_79]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79]
    at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79]
    at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
    at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]
    at app.angularjs.ServiceWrapperHome$$$view7.printDownloadFilePentaho(Unknown Source) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_79]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79]
    at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79]
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.2.Final.jar:]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:518) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33)
    at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:801)
    at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45)
    at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:821)
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
    Caused by: org.postgresql.util.PSQLException: FATALE: il database "${DatabaseName}" non esiste
    at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:572) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:177) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.Driver.makeConnection(Driver.java:410) [postgresql-9.3-1100.jdbc4.jar:]
    at org.postgresql.Driver.connect(Driver.java:280) [postgresql-9.3-1100.jdbc4.jar:]
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.DriverConnectionProvider.createConnection(DriverConnectionProvider.java:121) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.getConnection(SimpleSQLReportDataFactory.java:124) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.getReferencedFields(SimpleSQLReportDataFactory.java:211) [pentaho-reporting-engine-classic-core-6.1.0.1-196.jar:6.1.0.1-196.-1]
    ... 91 more

  4. #4
    Join Date
    May 2014
    Posts
    358

    Default

    If your only reason to do this is to differentiate between dev/test/prod environments, I would suggest using a JNDI connection.

  5. #5

    Default

    Did you ever find a solution for this?

  6. #6
    Join Date
    May 2014
    Posts
    358

    Default

    Yes, it's called a JNDI connection! The report only holds the name of the connection and the connection itself is configured on the server.

  7. #7

    Default

    Quote Originally Posted by Lukfi View Post
    Yes, it's called a JNDI connection! The report only holds the name of the connection and the connection itself is configured on the server.

    Can you tell me how? I looked for the "simple-jndi" folder under the .pentaho folder, but it is missing. I copied as pasted the one from the "configuration-template" folder inside of the Report Designer folder and that did not work either. Can you please help?

  8. #8
    Join Date
    Apr 2016
    Posts
    16

    Default

    Other way , you can try to using property file to customise configuring your Db.

  9. #9
    Join Date
    Apr 2016
    Posts
    9

    Default

    Here's how you make the JNDI connection
    https://help.pentaho.com/Documentati...60/010/030/020

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.