Tribune

Home » Liferay Portal » English » Liferay Legacy

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
saurabh joshi
error while connecting the portlet to database through JSTL
15 ottobre 2007 3.59
Risposta

saurabh joshi

Punteggio: Junior Member

Messaggi: 51

Data di Iscrizione: 6 agosto 2007

Messaggi recenti

Hi,

I am using JSTL to write the jsp file which will be having a connection to the database.
My code goes like this
 1<%@ include file="/html/portlet/ext/drpdwn/init.jsp" %>
 2
 3<sql:setDataSource  var="example"  driver="org.postgresql.Driver" url="jdbc:postgresql://10.10.33.39:5432/globus_db"
 4user="postgres"  password="marines@123"/>
 5
 6<sql:transaction dataSource="example">
 7<sql:query var="deejays">
 8    SELECT test1 FROM testing
 9</sql:query>
10</sql:transaction>

And I am getting the following error:
javax.servlet.ServletException: Error getting connection: "No suitable driver"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.test_jsp._jspService(test_jsp.java:583)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.liferay.filters.strip.StripFilter.doFilter(StripFilter.java:95)
com.liferay.filters.compression.CompressionFilter.doFilter(CompressionFilter.java:116)
com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:136)


I have proper .jar file(postgresql-8.3dev-601.jdbc3.jar) at C:\LiferayTomcat\common\lib\ext

Please Help in solving this issue

Regards,
Saurabh
Roman Hoyenko
RE: error while connecting the portlet to database through JSTL
15 ottobre 2007 8.17
Risposta

Roman Hoyenko

Punteggio: Liferay Master

Messaggi: 868

Data di Iscrizione: 8 ottobre 2007

Messaggi recenti

I had a similar error and couldn't figure out how to fix it, so I am interested in how to do it as well.
I tried to put a jar in a lot of different places, but it never worked.

I ended up doing this:

InitialContext ctxt = new InitialContext();
DataSource ds = (DataSource) ctxt.lookup("java:comp/env/jdbc/LiferayPool");
Connection conn = ds.getConnection();

Statement sth = conn.createStatement();
ResultSet rst = sth.executeQuery("select groupId, name from Group_ where friendlyURL='"+"/"+mainMenuFriendlyURL +"'");

It worked ok, but I couldn't use another datasource
Nay be you need to register data in liferay-ds.xml, but just adding a new one there didn't work.

The strange thing is that if I write my queries in java class it finds the driver just fine.
saurabh joshi
RE: error while connecting the portlet to database through JSTL
15 ottobre 2007 22.46
Risposta

saurabh joshi

Punteggio: Junior Member

Messaggi: 51

Data di Iscrizione: 6 agosto 2007

Messaggi recenti

Hi Roman,

As you have put this point then this might be the reason,
this error happens when you don't register the JDBC driver. And we can do that manually (Class.forName("your.jdbc.driver.class")), or put the correct driver name in your pool settings.

I asume this might be the reason?

What do you say?

Regards,
Saurabh.
saurabh joshi
RE: error while connecting the portlet to database through JSTL
16 ottobre 2007 2.47
Risposta

saurabh joshi

Punteggio: Junior Member

Messaggi: 51

Data di Iscrizione: 6 agosto 2007

Messaggi recenti

Hey...

I found it!!

Just do the following,
For running the JSP with JSTL in portlets
_________________________________________

take the JDBC jar file in my case (postgresql-8.3dev-601.jdbc3.jar)
and put it into
C:\Program Files\Java\j2re1.4.1_07\lib\ext
next also put it into
C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib

next you set classpath :
C:\LiferayTomcat\common\lib\servlet-api.jar;C:\Program Files\Java\jre1.5.0_12\lib\ext\postgresql-8.3dev-601.jdbc3.jar;C:\Program Files\Java\jdk1.5.0_12\bin


Try that and let me know if it worked for you or not!!

Regards,
Saurabh.