views:

22

answers:

1

In this stackoverflow question the poster implies that you can set zeroDateTimeBehavior="convertToNull" as an attribute on the tag.

Does anyone know if this should be possible? All the docs I've looked at say that you can only add this property on the database connection url.

I'm actually looking for a way to set this property on the DataSource from within the Spring context, so that we don't have to go around and update all our various environments, or risk losing property this should someone need to change the connection url.

A Spring configured DataSource makes it very easy:

<bean id="propsDataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
  <property name="url" value="${connection.url}"/>
  <property name="user" value="${connection.username}"/>
  <property name="password" value="${connection.password}"/>
  <property name="zeroDateTimeBehavior" value="convertToNull"/>
 </bean>

Does anyone know how to do this through a JNDI configured DataSource?

Thanks,

A: 

The docs at http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html state it should be passed on the URL.

Can you try if this works for you?

<ResourceParams name="jdbc/DataSourceName">
                    <parameter>
                         <name>zeroDateTimeBehavior</name>
                         <value>convertToNull</value>
                     </parameter>
</ResourceParams> 
JoseK
I'm afraid not :-(
Stewart