You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Anthony Perritano <ap...@gmail.com> on 2006/03/14 02:25:31 UTC
portlet DB connection
Hi,
I have a portlet that i want to access a mysql database. i keep
running into this:
Error on SQL: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot
create JDBC driver of class '' for connect URL 'null'
looks like jetspeed.xml
<Context path="/jetspeed" docBase="jetspeed" crossContext="true">
<Realm className="org.apache.catalina.realm.JAASRealm"
appName="Jetspeed"
userClassNames="org.apache.jetspeed.security.impl.UserPrincipalImpl"
roleClassNames="org.apache.jetspeed.security.impl.RolePrincipalImpl"
useContextClassLoader="false"
debug="0"/>
<Resource name="jdbc/jetspeed" auth="Container"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
type="javax.sql.DataSource" username="jetspeed2"
password="jetspeed2"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://blah:3306/j2"
maxActive="100" maxIdle="30" maxWait="10000"/>
<Resource name="jdbc/sailDB" auth="Container"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
type="javax.sql.DataSource" username="jetspeed2"
password="j2"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://blah:3306/sail"
maxActive="100" maxIdle="30" maxWait="10000"/>
</Context>
the jdbc/jetspeed works great, its the jdbc/sailDB that i am trying
to connect to from my portlet.
my datasource.xml has this:
<bean id="sailDB"
class="org.apache.jetspeed.components.rdbms.ojb.ConnectionRepositoryEntr
y">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://blah:3306/sail</value>
</property>
<property name="username">
<value>jetspeed2</value>
</property>
<property name="password">
<value>j2</value>
</property>
<property name="jndiName">
<value>java:comp/env/jdbc/sailDB</value>
</property>
</bean>
my web.xml in my portlet is:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/sailDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
and the code i use to get the datasource in my portlet is:
DataSource ds = null;
Context context = new InitialContext();
ds = (DataSource) context.lookup("java:comp/env/jdbc/sailDB");
am missing something some where???
thanks
Anthony
Re: portlet DB connection
Posted by Raj Saini <ra...@gmail.com>.
Anthony,
Why you need Jetspeed specific DataSource for conencting to your
portlet application database?
I would suggest you to configure a separate data source in your
portlet application and use it for accessing database from your
portlet.
You will need to do the following?
1. Configure data source in server.xml or your application context
specific xml fragment.
2. Get reference to DataSource in your application using InitialContext.
3. Do whatever you want to do with database from within your application.
Regards,
Raj
On 3/14/06, Anthony Perritano <ap...@gmail.com> wrote:
> Hi,
> I have a portlet that i want to access a mysql database. i keep
> running into this:
>
> Error on SQL: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot
> create JDBC driver of class '' for connect URL 'null'
>
> looks like jetspeed.xml
>
> <Context path="/jetspeed" docBase="jetspeed" crossContext="true">
>
> <Realm className="org.apache.catalina.realm.JAASRealm"
> appName="Jetspeed"
>
> userClassNames="org.apache.jetspeed.security.impl.UserPrincipalImpl"
>
> roleClassNames="org.apache.jetspeed.security.impl.RolePrincipalImpl"
> useContextClassLoader="false"
> debug="0"/>
>
>
> <Resource name="jdbc/jetspeed" auth="Container"
> factory="org.apache.commons.dbcp.BasicDataSourceFactory"
> type="javax.sql.DataSource" username="jetspeed2"
> password="jetspeed2"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://blah:3306/j2"
> maxActive="100" maxIdle="30" maxWait="10000"/>
>
> <Resource name="jdbc/sailDB" auth="Container"
> factory="org.apache.commons.dbcp.BasicDataSourceFactory"
> type="javax.sql.DataSource" username="jetspeed2"
> password="j2"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://blah:3306/sail"
> maxActive="100" maxIdle="30" maxWait="10000"/>
> </Context>
>
> the jdbc/jetspeed works great, its the jdbc/sailDB that i am trying
> to connect to from my portlet.
>
> my datasource.xml has this:
>
> <bean id="sailDB"
> class="org.apache.jetspeed.components.rdbms.ojb.ConnectionRepositoryEntr
> y">
> <property name="driverClassName">
> <value>com.mysql.jdbc.Driver</value>
> </property>
> <property name="url">
> <value>jdbc:mysql://blah:3306/sail</value>
> </property>
> <property name="username">
> <value>jetspeed2</value>
> </property>
> <property name="password">
> <value>j2</value>
> </property>
> <property name="jndiName">
> <value>java:comp/env/jdbc/sailDB</value>
> </property>
> </bean>
>
> my web.xml in my portlet is:
>
> <resource-ref>
> <description>DB Connection</description>
> <res-ref-name>jdbc/sailDB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> and the code i use to get the datasource in my portlet is:
>
> DataSource ds = null;
>
> Context context = new InitialContext();
>
> ds = (DataSource) context.lookup("java:comp/env/jdbc/sailDB");
>
>
> am missing something some where???
>
> thanks
> Anthony
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org
Re: portlet DB connection
Posted by David Sean Taylor <da...@bluesunrise.com>.
A couple of observations
1. assuming you are running from the svn trunk (not the 2.0 release)
2. Ive recently stopped using the ConnectionRepositoryEntry, so it is
not initialized
3. Not sure how you expect to find it the CRE from your portlet class,
as the class lives in the Jetspeed webapp. (Perhaps some classloader
tricks come into play here). Or are you packaging our rdbms jar in your
portlet app?
Anthony Perritano wrote:
> Hi,
> I have a portlet that i want to access a mysql database. i keep running
> into this:
>
> Error on SQL: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot
> create JDBC driver of class '' for connect URL 'null'
>
> looks like jetspeed.xml
>
> <Context path="/jetspeed" docBase="jetspeed" crossContext="true">
>
> <Realm className="org.apache.catalina.realm.JAASRealm"
> appName="Jetspeed"
>
> userClassNames="org.apache.jetspeed.security.impl.UserPrincipalImpl"
>
> roleClassNames="org.apache.jetspeed.security.impl.RolePrincipalImpl"
> useContextClassLoader="false"
> debug="0"/>
>
>
> <Resource name="jdbc/jetspeed" auth="Container"
> factory="org.apache.commons.dbcp.BasicDataSourceFactory"
> type="javax.sql.DataSource" username="jetspeed2"
> password="jetspeed2"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://blah:3306/j2"
> maxActive="100" maxIdle="30" maxWait="10000"/>
>
> <Resource name="jdbc/sailDB" auth="Container"
> factory="org.apache.commons.dbcp.BasicDataSourceFactory"
> type="javax.sql.DataSource" username="jetspeed2" password="j2"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://blah:3306/sail"
> maxActive="100" maxIdle="30" maxWait="10000"/>
> </Context>
>
> the jdbc/jetspeed works great, its the jdbc/sailDB that i am trying to
> connect to from my portlet.
>
> my datasource.xml has this:
>
> <bean id="sailDB"
> class="org.apache.jetspeed.components.rdbms.ojb.ConnectionRepositoryEntr
> y">
> <property name="driverClassName">
> <value>com.mysql.jdbc.Driver</value>
> </property>
> <property name="url">
> <value>jdbc:mysql://blah:3306/sail</value>
> </property>
> <property name="username">
> <value>jetspeed2</value>
> </property>
> <property name="password">
> <value>j2</value>
> </property>
> <property name="jndiName">
> <value>java:comp/env/jdbc/sailDB</value>
> </property>
> </bean>
>
> my web.xml in my portlet is:
>
> <resource-ref>
> <description>DB Connection</description>
> <res-ref-name>jdbc/sailDB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
> and the code i use to get the datasource in my portlet is:
>
> DataSource ds = null;
>
> Context context = new InitialContext();
>
> ds = (DataSource) context.lookup("java:comp/env/jdbc/sailDB");
>
>
> am missing something some where???
>
> thanks
> Anthony
>
>
>
>
--
David Sean Taylor
Bluesunrise Software
david@bluesunrise.com
[office] +01 707 773-4646
[mobile] +01 707 529 9194
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org