ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manu <maxn...@hotmail.com>
Subject Re: Ignite Jdbc connection
Date Mon, 24 Oct 2016 12:42:38 GMT
Hi,

as you know, org.apache.ignite.internal.jdbc2.JdbcConnection is an
implementation of java.sql.Connection, works always on client mode (this
flag is hardcoded to true when load xml configuration passed on connection
url) and works on read mode (only select). On same java VM instance,
connection (ignite instance) is cached internally in JdbcConnection by url,
so for same connection (type, path, collocation...) you only have (and need)
one ignite instance. For more info check this 
https://apacheignite.readme.io/docs/jdbc-driver
<https://apacheignite.readme.io/docs/jdbc-driver>  

As a java.sql.Connection, you could use a javax.sql.DataSource
implementation to manage it and checks connection status (validation query)
etc, but you don't need a pool, for example:

		<spring:bean id="collocatedDbcpIgniteDataGridDataSource"
destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
		    <spring:property name="driverClassName"
value="org.apache.ignite.IgniteJdbcDriver"/>
		    <spring:property name="url"
value="jdbc:ignite:cfg://cache=default:collocated=true:local=false@ignite/data_grid/ignite-client.xml"/>
		    <spring:property name="validationQuery" value="select count(*) from
&quot;default&quot;.string limit 1"/>
		    <spring:property name="removeAbandoned" value="true"/>
		    <spring:property name="removeAbandonedTimeout" value="300"/>
		    <spring:property name="logAbandoned" value="true"/>
		</spring:bean> 


[...]
This is client ignite configuration with default cache (dummy, without data,
only used to validate client connection) used on url of
collocatedDbcpIgniteDataGridDataSource

	<bean  id="ignite.client.default.cfg.jdbc"
class="org.apache.ignite.configuration.IgniteConfiguration">
		<property name="clientMode" value="true" />
		<property name="peerClassLoadingEnabled" value="false" />
		<property name="metricsLogFrequency" value="0"/>
    	</property>	
	    <property name="cacheConfiguration">
   			<list>
				<bean class="org.apache.ignite.configuration.CacheConfiguration">
					<property name=&quot;name&quot; value=&quot;&lt;b>default*" />
					<property name="cacheMode" value="PARTITIONED" />
					<property name="indexedTypes">
						<array>
							<value>java.lang.String</value>
							<value>java.lang.String</value>	
						</array>
					</property>								
				</bean>
[...]



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-Jdbc-connection-tp8431p8436.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message