Updating a row by rowid in oracle using spring-jdbc - oracle

I have a weird problem updating a row by rowid in oracle using spring-jdbc.
The problem is that everything is ok but for some rowids the update will never be done and
application is frozen.
I changed spring log level to DEBUG to see what's happening but nothing's strange and spring log is exactly as successful updates.
I tried to execute the same sql in plsql and the update was executed successfully.
spring version is 3.1.1.RELEASE
oracle version is 11.1.0.6.0
body of update method in dao is:
String sql=
"UPDATE "+schema+".MSG m SET m.STATE="+state+" WHERE ROWID='"+msg.getRowId()+"'";
getJdbcTemplate().update(sql);
dao bean:
<bean id="messageDao" class="com.foo.dao.springjdbc.MessageDaoSpringJdbcImpl">
<property name="jdbcTemplate" ref="jdbcTemplate"/>
</bean>
jdbcTemplate:
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
data source:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:#${db.ip}:${db.port}:${db.sid}"/>
<property name="username" value="${db.username}"/>
<property name="password" value="${db.password}"/>
<property name="validationQuery" value="select 1 from dual"/>
<property name="testOnBorrow" value="true"/>
<property name="testWhileIdle" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="5000"/>
<property name="numTestsPerEvictionRun" value="3"/>
<property name="maxActive" value="1"/>
<property name="maxIdle" value="3"/>
</bean>
any idea?

Related

jasypt EncryptablePropertyPlaceholderConfigurer not helping in decrypting the password

I started doing some examples using Jasypt and Spring and unfortunately, could not test the decryption successfully.
I'm using Spring 4.3.15 and Jasypt 1.9.3. I think I followed the examples given in the internet carefully, but still see the password is sent encrypted only.
My spring configuration looks like below
<bean id="mydatasource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<bean id="encryptedPropertyPlaceHolder" class=**"org.jasypt.spring4.properties.EncryptablePropertyPlaceholderConfigurer"**>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="ignoreResourceNotFound" value="true" />
<constructor-arg>
<bean class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config">
<bean class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
<property name="algorithm" value="PBEWithMD5AndDES" />
***<!-- <property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" /> -->***
<property name="password" value="jasypt" />
</bean>
</property>
</bean>
</constructor-arg>
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
and jdbc.properties has values
jdbc.url=<<some url>>
jdbc.username=<<some username>>
jdbc.password=ENC(Y3EEFmt5lEAC96GJlzK9VcETH)
When I ran my testcase, which uses mydatasource as Autowired, I see that password field is set as ENC(Y3EEFmt5lEAC96GJlzK9VcETH). Other fields are properly assigned using propertyConfigurer. But the encrypted password is not decrypted before assigning to datasource.
I'm not sure, what is that I'm missing here ?
Also, as you noticed I used hard coded password in encryptedPropertyPlaceHolder. I have read about APP_ENCRYPTION_PASSWORD, but when trying to set the value using VM arguments in my eclipse as -DAPP_ENCRYPTION_PASSWORD=jasypt, it is not working.

mysql clustering connection is failed through hibernate and spring

Using MySQL workbench I can connect to the cluster db without any issue. but when I use it as the connection string jdbc:mysql:loadbalance://node_ip1,node_ip2,node_ip3/cluster_db_name?loadBalanceBlacklistTimeout=5000&loadBalanceStrategy=bestResponseTime from the app it will give me an error saying connection timeout. After that I use one cluster node and try to connect to it as we connect to localhost jdbc:mysql://cluster_node1/cluster_db_name?relaxAutoCommit=true&autoReconnect=true&useUnicode=true&connectionCollation=utf8_general_ci&characterEncoding=utf8&characterSetResults=utf8 but it also gives me the same error.
Below is the applicationContext.xml code.
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${bluesky.jdbc.driver}"/>
<property name="jdbcUrl" value="${bluesky.jdbc.url}"/>
<property name="user" value="${bluesky.jdbc.username}"/>
<property name="password" value="${bluesky.jdbc.password}"/>
<property name="minPoolSize" value="${bluesky.c3p0.pool.min.size}"/>
<property name="maxPoolSize" value="${bluesky.c3p0.pool.max.size}"/>
<property name="numHelperThreads" value="${bluesky.c3p0.numHelperThreads}"/>
<property name="acquireIncrement" value="${bluesky.c3p0.acquireIncrement}"/>
<property name="acquireRetryAttempts" value="${bluesky.c3p0.acquireRetryAttempts}"/>
<property name="idleConnectionTestPeriod" value="${bluesky.c3p0.idleConnectionTestPeriod}"/>
<property name="maxIdleTime" value="${bluesky.c3p0.maxIdleTime}"/>
<property name="preferredTestQuery" value="${bluesky.c3p0.preferred.test.query}"/>
<property name="testConnectionOnCheckout" value="${bluesky.c3p0.test.connection.on.checkout}"/>
<property name="testConnectionOnCheckin" value="${bluesky.c3p0.test.connection.on.checkin}"/>
<property name="checkoutTimeout" value="${bluesky.c3p0.checkout.timeout}"/>
<property name="debugUnreturnedConnectionStackTraces" value="${bluesky.c3p0.debug.unreturned.connection.stackTraces}"/>
<property name="unreturnedConnectionTimeout" value="${bluesky.c3p0.unreturned.connection.timeout}"/>
</bean>

Spring integration jdbc message store performance

I was using the SimpleMessageStore ( memory ) as the default Store for an Aggregator, but as i need
persistent store, i started using a jdbc solution backed up by Mysql 5.5
But i'm really concerned about its performance, as using a PerfTest ( databene's contiperf ), memory store achieved up to 6000 messages/sec, whereas using mysql ( or redis, or mongo ), i can't achieve more than 15-20 messages/sec.
<int:aggregator id="XDRAggegator"
input-channel="mqChannel"
output-channel="publishChannel"
message-store="jdbc-messageStore"
....
<bean id="reaper" class="org.springframework.integration.store.MessageGroupStoreReaper">
<property name="messageGroupStore" ref="jdbc-messageStore"/>
<property name="timeout" value="${msg.timeout}"/>
</bean>
<task:scheduler id="taskScheduler"/>
<task:scheduled-tasks scheduler="taskScheduler">
<task:scheduled ref="reaper" method="run" fixed-rate="${reaper.rate}"/>
</task:scheduled-tasks>
<task:executor id="taskExecutor" pool-size="1"/>
<task:annotation-driven executor="taskExecutor" scheduler="taskScheduler"/>
<int-jdbc:message-store id="jdbc-messageStore" data-source="dataSource" />
<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" >
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://${database.host}:3306/XDR?autoReconnect=true&cachePrepStmts=true&prepStmtCacheSize=50" />
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
<property name="idleConnectionTestPeriodInMinutes" value="1"/>
<property name="idleMaxAgeInMinutes" value="2"/>
<property name="connectionTimeoutInMs" value="1000" />
<property name="maxConnectionsPerPartition" value="10"/>
<property name="minConnectionsPerPartition" value="4"/>
<property name="partitionCount" value="4"/>
<property name="acquireIncrement" value="2"/>
<property name="statementsCacheSize" value="10"/>
<property name="closeConnectionWatch" value="false"/>
</bean>
Am i missing something ?
I'm using default schema that comes into spring-integration-jdbc library.

Mule to JPA compatibility

I using Mule Studio version: 1.3.1 .
buildDate: 201209061215
I am not able to get JPA end point. I also downloaded jpa-connector-1.0-20120925-2201.jar
But I dont know to to integrate with mule studio.
So I decided to use a simple Java transformer and write my processing logic which will be internally using JPA/Hibernate.
I came to know that i have to use a JPA vendor adapter for spring, else none of my service, DAO classes will be instantiated.
I have declared a datasource and entityManager as beans of spring inside mule flow xml as shown.
<spring:bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<spring:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<spring:property name="url" value="jdbc:mysql://localhost:3306/eigDB" />
<spring:property name="username" value="root" />
<spring:property name="password" value="tiger" />
</spring:bean>
<spring:bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<spring:property name="dataSource" ref="dataSource" />
<spring:property name="persistenceUnitName" value="autoRebateSystem" />
<spring:property name="jpaVendorAdapter">
<spring:bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<spring:property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
<spring:property name="showSql" value="true" />
</spring:bean>
But mule flow xml is not able to recognize any class of spring framework.
Finding very difficult to replace those class names.
Plez provide the solution for my problem,
By letting me know the PROPER replacements for mule studio.
1) org.springframework.jdbc.datasource.DriverManagerDataSource
2) org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
3) org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
Are you missing to use HibernateJpaDialect and JpaTransactionManager;
I hope the following configuration will be useful.
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/yourdatabase"/>
<property name="username" value="your- username"/>
<property name="password" value="your- password"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!--<property name="dataSource" ref="dataSource"/>-->
<property name="persistenceUnitName" value="<your-persistunit-name>"/>
<property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect/>
</property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver">
</bean>
</property>
</bean>
<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.MySQLPlatform"/>
<!-- <property name="databasePlatform" value="org.eclipse.persistence.platform.database.OraclePlatform" />-->
<property name="generateDdl" value="false"/>
<property name="showSql" value="false"/>
</bean>
To integrate it within MuleStudio, please add this update site within MuleStudio:
http://tecnologia.2020mobile.es/jpa-cloud-connector/update-site/

How to set program name in ibatis config XML?

I am attempting to set the program name to something other than "jdbc thin client" using the iBatis dao config.
From my dao XML config file:
<transactionManager type="JDBC">
<dataSource type="DBCP">
<property name="JDBC.Driver" value="com.foo.bar.jdbc.MyOracleDriver"/>
<property name="JDBC.ConnectionURL" value="oracle.jdbc.OracleDriver&jdbc:oracle:thin:#${host}:1521:${database}"/>
<property name="JDBC.Username" value="${userName}"/>
<property name="JDBC.Password" value="${password}"/>
<property name="Pool.DefaultAutoCommit" value="false"/>
<property name="Pool.MaximumActiveConnections" value="63"/>
<property name="Pool.MaximumIdleConnections" value="10"/>
<property name="Pool.MaximumWait" value="2000"/>
<property name="Pool.ValidationQuery" value="select 1 from dual"/>
<property name="Pool.testWhileIdle" value="true"/>
<property name="Pool.TestOnBorrow" value="true"/>
<property name="Pool.LogAbandoned" value="true"/>
<property name="Pool.RemoveAbandoned" value="true"/>
<property name="Pool.RemoveAbandonedTimeout" value="300"/>
</dataSource>
</transactionManager>
I would assume this is as easy as adding the following:
<property name="v$session.program" value="My Program Name"/>
But that didn't work. The program name did not change. What am I doing wrong?

Resources