PDA

View Full Version : Problem using PentahoConnectionFactory



csylvester
09-11-2006, 09:19 PM
I am having a problem using the PentahoConnectionFactory to connect to a MySQL database. Here is the error in the JBoss server log:

-----------------------------------------------------------------------
2006-09-11 23:21:12,554 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/pentaho].[
jsp]] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.pentaho.data.connection.sql.SQLConnection.init(SQLConnection.java:100)
at org.pentaho.data.connection.sql.SQLConnection.<init>(SQLConnection.java:72)
at org.pentaho.data.PentahoConnectionFactory.getConnection(PentahoConnectionFactory.java:135)
at org.apache.jsp.jsp.MySQL_005fDialMonth_jsp._jspService(MySQL_005fDialMonth_jsp.java:78)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:25
2)
-------------------------------------

I've tried searching the web and looking through the source and am not having any luck finding what I am missing. Below is the code I am attempting to run.

--------------------------------------
<%@ page language="java"
import="java.util.ArrayList,
org.pentaho.core.ui.SimpleUrlFactory,
org.pentaho.messages.Messages,
org.pentaho.core.system.PentahoSystem,
org.pentaho.ui.component.DashboardWidgetComponent,
org.pentaho.core.solution.HttpRequestParameterProvider,
org.pentaho.core.solution.HttpSessionParameterProvider,
org.pentaho.data.PentahoConnectionFactory,
org.pentaho.core.session.IPentahoSession,
org.pentaho.core.connection.IPentahoConnection,
org.pentaho.core.connection.IPentahoResultSet,
org.pentaho.core.util.UIUtil,
org.pentaho.util.VersionHelper,
org.pentaho.messages.util.LocaleHelper,
org.pentaho.core.solution.ActionResource,
org.pentaho.core.solution.IActionResource,
java.io.*"
%>
<%

IPentahoConnection connection = PentahoConnectionFactory.getConnection(
0,
"com.mysql.jdbc.Driver",
"jdbc:mysql://localhost;database=datamart",
"csylvester",
"password",
null);

-----------------------------

Any help would be greatly appreciated.

BTW, I am attempting to set up a web page that displays a series of three dials and the code above is to get the value for one of the dials. If there is a better way to do this (i.e, display a dial with the value coming from a database), I would appreciate any pointers.

Thanks in advance,
Craig

mbatchelor
09-13-2006, 03:12 PM
I recommend modifying one of the given datasourcex-ds.xml with your connection information, and getting the connection using JNDI instead of the driver-manager call.

Also, were you sure to copy the JDBC driver jar file(s) to the server/default/lib directory?

Take care,

Marc

csylvester
09-14-2006, 01:29 PM
Thanks Marc.

Using this method:

IPentahoConnection connection = PentahoConnectionFactory.getConnection(PentahoConnectionFactory.SQL_DATASOURCE, "MySQL", null); //$NON-NLS-1$

solved the problem.

Now onto the next problem :-)

Regards,
Craig

martin.novoty
11-22-2010, 06:09 PM
Dear all,

In version 2.0. I have problems to create connection without session object as it is required to be run as scheduled job.

Any hints how to get IPentahoConnection ?