You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by deligeli <od...@jpost.com> on 2009/11/05 19:44:50 UTC

check if a connection is valid in IBatis

hi

my code is like that:

public Clip getVideoById(String videoId)  throws SQLException{
		return (Clip) sqlMapper.queryForObject("getVideoById",videoId);
	}

how can i make sure that the connection to the database is valid and if not
to open it?
-- 
View this message in context: http://old.nabble.com/check-if-a-connection-is-valid-in-IBatis-tp26217372p26217372.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: check if a connection is valid in IBatis

Posted by NickSTL <NB...@express-scripts.com>.
The ping options can be set in the config XML like so.  The Pool.* options
are what you need.  This is just an example, you should set whatever timeout
parameters you need (in ms).

<transactionManager type="JDBC">
		<dataSource type="SIMPLE">
			<property name="JDBC.Driver" value="${driver}"/>
			<property name="JDBC.ConnectionURL" value="${url}"/>
			<property name="JDBC.Username" value="${user}"/>
			<property name="JDBC.Password" value="${password}"/>
			
			<property name="Pool.TimeToWait" value="2000"/>
           	                          <property name="Pool.PingQuery"
value="SELECT 1"/>
                          	<property name="Pool.PingEnabled" value="true"/>
           	           	           	<property
name="Pool.PingConnectionsOlderThan" value="600000"/>
			<property name="Pool.PingConnectionsNotUsedFor" value="600000"/> 
		</dataSource>
	</transactionManager>	

Hopefully this helps you!  Take a look at the javadoc for
com.ibatis.common.jdbc.SimpleDataSource for the rull list of pool options.

Nick
-- 
View this message in context: http://old.nabble.com/check-if-a-connection-is-valid-in-IBatis-tp26217372p26230808.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: check if a connection is valid in IBatis

Posted by deligeli <od...@jpost.com>.
hi

i read that i should use PingQuery

what is it? how does it work? and how should i use it?


deligeli wrote:
> 
> hi
> 
> my code is like that:
> 
> public Clip getVideoById(String videoId)  throws SQLException{
> 		return (Clip) sqlMapper.queryForObject("getVideoById",videoId);
> 	}
> 
> how can i make sure that the connection to the database is valid and if
> not to open it?
> 

-- 
View this message in context: http://old.nabble.com/check-if-a-connection-is-valid-in-IBatis-tp26217372p26219832.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org