Ich verwende iBatis für den DatenBank- Zugriff,
Weiß jemand, wie ich ein reconnect mit iBatis machen kann ohne das Programm neu zu starten?
lg
Weiß jemand, wie ich ein reconnect mit iBatis machen kann ohne das Programm neu zu starten?
lg
static {
String resource = "DBXML/SqlMapConfig.xml";
Reader reader = Resources.getResourceAsReader(resource);
sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
}
...hmm, also mein englisch ist zwar das mieseste das es gibt, jedoch bin ich auf Seite 42 des Entwicklerhandbuches auf folgendes gestoßen:... Im Tutorial steht auf jeden Fall nichts drinnen, wie man sich wieder verbinden kann ...
..da heißt es zwar nicht explicit reconnect, jedoch was verstehst Du unter Caching Mapped?Caching Mapped Statement Results
The results from a Query Mapped Statement can be cached simply by specifying the cacheModel parameter
in the statement tag (seen above). A cache model is a configured cache that is defined within your SQL
map. Cache models are configured using the cacheModel element as follows:
<cacheModel id="product-cache" type ="LRU" readOnly=”true” serialize=”false”>
<flushInterval hours="24"/>
<flushOnExecute statement="insertProduct"/>
<flushOnExecute statement="updateProduct"/>
<flushOnExecute statement="deleteProduct"/>
<property name=”cache-size” value=”1000” />
</cacheModel>
The cache model above will create an instance of a cache named “product-cache” that uses a Least Recently
Used (LRU) implementation. The value of the type attribute is either a fully qualified class name, or an
alias for one of the included implementations (see below). Based on the flush elements specified within the
cache model, this cache will be flushed every 24 hours. There can be only one flush interval element and it
can be set using hours, minutes, seconds or milliseconds. In addition the cache will be completely flushed
whenever the insertProduct, updateProduct, or deleteProduct mapped statements are executed. There can
be any number of “flush on execute” elements specified for a cache. Some cache implementations may
need additional properties, such as the ‘cache-size’ property demonstrated above. In the case of the LRU
cache, the size determines the number of entries to store in the cache. Once a cache model is configured,
you can specify the cache model to be used by a mapped statement, for example:
<select id=”getProductList” cacheModel=”product-cache”>
select * from PRODUCT where PRD_CAT_ID = #value#
</select>
..nochmals hervorgehoben!Based on the flush elements specified within the
cache model, this cache will be flushed every 24 hours. There can be only one flush interval element and it
can be set using hours, minutes, seconds or milliseconds. In addition the cache will be completely flushed
whenever the insertProduct, updateProduct, or deleteProduct mapped statements are executed. There can
be any number of “flush on execute” elements specified for a cache.
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="120000"/>
Fehler in der Klasse DBReader beim Auslesen aus der AlarmTabelle: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in DBXML/DBAlarmeReadBean.xml.
--- The error occurred while executing query.
--- Check the SELECT KOMMEN as kommen, GEHEN
as gehen, QUIT as quit, ALARMNR as alarmNr, VAR1 as var1, VAR2 as var2
FROM Alarme WHERE KOMMEN BETWEEN ? AND ? ORDER BY KOMMEN .
--- Check the SQL Statement (preparation failed).
--- Cause: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544721. Unable to complete network request to host "".
Reason: Unable to complete network request to host "".
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544721. Unable to complete network request to host "".
Reason: Unable to complete network request to host "".
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties resource="DBXML/DatenbankKonfig.properties" />
<settings
cacheModelsEnabled ="true"
enhancementEnabled ="true"
lazyLoadingEnabled ="true"
maxRequests ="20"
maxSessions ="10"
maxTransactions ="5"
useStatementNamespaces ="false"
statementCachingEnabled ="true"
classInfoCacheEnabled ="true"
/>
<transactionManager type="JDBC" >
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}" />
<property name="JDBC.ConnectionURL" value="${url}" />
<property name="JDBC.Username" value="${username}" />
<property name="JDBC.Password" value="${password}" />
<property name="JDBC.DefaultAutoCommit" value="true" />
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="120000"/>
<property name="Pool.TimeToWait" value="500"/>
<property name="Pool.PingQuery" value="select 1 from ACCOUNT"/>
<property name="Pool.PingEnabled" value="false"/>
<property name="Pool.PingConnectionsOlderThan" value="1"/>
<property name="Pool.PingConnectionsNotUsedFor" value="1"/>
</dataSource>
</transactionManager>
<sqlMap resource="DBXML/DBWertReadBean.xml" />
<sqlMap resource="DBXML/DBAlarmeReadBean.xml" />
</sqlMapConfig>
resource = "DBXML/SqlMapConfig.xml";
reader = Resources.getResourceAsReader(resource);
sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
private static SqlMapClient sqlMap;
...
try {
String resource = "DBXML/SqlMapConfig.xml";
reader = Resources.getResourceAsReader(resource);
sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
}
catch (Exception e)
{
// hier gebe ich eine Fehlermeldung aus (catch ist nicht leer)
}
wa.setZeitstempel1(new Timestamp(new Date(calendar.getTimeInMillis()).getTime()));
wa.setZeitstempel2(new Timestamp(aktuell.getTime()));
alarmeList = sqlMap.queryForList("getAlarme", wa);
Fehler in der Klasse DBReader beim Auslesen aus der AlarmTabelle: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in DBXML/DBAlarmeReadBean.xml.
--- The error occurred while executing query.
--- Check the SELECT KOMMEN as kommen,
GEHEN as gehen, QUIT as quit, ALARMNR as alarmNr, VAR1 as var1, VAR2
as var2 FROM Alarme WHERE KOMMEN BETWEEN ? AND ? ORDER BY KOMMEN .
--- Check the SQL Statement (preparation failed).
--- Cause: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544721. Unable to complete network request to host "".
Reason: Unable to complete network request to host "".
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544721. Unable to complete network request to host "".
Reason: Unable to complete network request to host "".
protected static SqlMapClient getSqlMapInstance ()
{
return sqlMap;
}
private SqlMapClient sqlMap = AppSqlConfig.getSqlMapInstance();
AppSqlConfig.getSqlMapInstance();