You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin <ke...@myway.com> on 2003/08/20 22:03:19 UTC
Oracle JDBC error
I am a newbie to Struts.
When I try to use the Oracle JDBC extension to take advantage of the Oracle batch update feature, I got an
exception "org.apache.commons.dbcp.DelegatingPreparedStatement"
It happens when I try to cast a PrepareStatement to OraclePreparedStatement. (It works fine without the cast)
Any idea why?
Here is the code snippet:
ServletContext context = servlet.getServletContext();
DataSource ds = (DataSource) context.getAttribute(Action.DATA_SOURCE_KEY);
try {
Connection conn = ds.getConnection();
String sql = "SELECT username FROM users";
OraclePreparedStatement ps = (OraclePreparedStatement) conn.prepareStatement(sql);
ResultSet rset = ps.executeQuery();
......
} catch ( Exception e ) {
System.out.println( e.getMessage() );
}
struts_config.xml:
<data-sources>
<data-source>
<set-property property="driverClass" value="oracle.jdbc.OracleDriver"/>
<set-property property="url" value="jdbc:oracle:thin:@hostname:1522:db"/>
<set-property property="maxCount" value="5"/>
<set-property property="minCount" value="1"/>
<set-property property="user" value="xxx"/>
<set-property property="password" value="xxx"/>
</data-source>
</data-sources>
Thanks for any help!
_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: [OT]Oracle JDBC error
Posted by Evan Schnell <es...@nvisia.com>.
Kevin wrote:
>I am a newbie to Struts.
>
>When I try to use the Oracle JDBC extension to take advantage of the Oracle batch update feature, I got an
>exception "org.apache.commons.dbcp.DelegatingPreparedStatement"
>It happens when I try to cast a PrepareStatement to OraclePreparedStatement. (It works fine without the cast)
>
>Any idea why?
>
>
What is going on here is that you are getting a commons connection pool
statement which wraps the Oracle statement but not an Oracle statement
itself.
What you are trying to do is not exactly sanctioned by J2EE. The
container has no obligation to give you a particular class of
DataSource, Connection, or Statement based upon the Driver class. It is
only required to give you something that implements the interface.
That said, I am not sure why you need to cast to a special Oracle
object; the java.sql.PreparedStatement interface supports batch updates
abstractly.
Evan.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: iterating through lists in tiles
Posted by Kevin Bootz <oh...@adelphia.net>.
I think you can add a bean define for the link and use it directly in a '<a
href=...' tag, such as;
<tiles:importAttribute/>
<logic:iterate name="items" id="item"/>
<logic:iterate name="links" id="link"/>
<!-- ===== link scripting var ===== -->
<bean:define id="linkName" name="link" property="pathToLink"
type="java.lang.String"/>
<a href="<%=linkName%>"><bean:write name="item"
property="someProperty"/></a>
<!-- ===== -->
</logic:iterate>
</logic:iterate>
-----Original Message-----
From: e [mailto:lists@medusadigital.com]
Sent: Wednesday, August 20, 2003 4:58 PM
To: Struts Users Mailing List
Subject: iterating through lists in tiles
I am trying to create a list of links using items from a putList in tiles.
The end result would be:
<a href="link">item</a>
<a href="link">item</a>
How do I iterate through both link and item in parallel, so to speak?
i.e. how do I modify the code below to get the result I want?
<tiles:importAttribute/>
<logic:iterate name="items" id="item"/>
<logic:iterate name="links" id="link"/>
<html:link page="<bean:write name="link"/>"><bean:write
name="item"/></html:link>
</logic:iterate>
</logic:iterate>
Thanks.
-eva
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
iterating through lists in tiles
Posted by e <li...@medusadigital.com>.
I am trying to create a list of links using items from a putList in tiles.
The end result would be:
<a href="link">item</a>
<a href="link">item</a>
How do I iterate through both link and item in parallel, so to speak?
i.e. how do I modify the code below to get the result I want?
<tiles:importAttribute/>
<logic:iterate name="items" id="item"/>
<logic:iterate name="links" id="link"/>
<html:link page="<bean:write name="link"/>"><bean:write
name="item"/></html:link>
</logic:iterate>
</logic:iterate>
Thanks.
-eva
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org