Is the Eclipselink connection pool meant to be used in production? - eclipselink

I am currently trying different connection pools together with eclipselink. The one I am currently configuring is the one by eclipselink itself. Now I am not sure if it is meant to be used in production or if I should use another such as HikariCP? Also I am not sure how to detect if the Eclipselink connection pool is really running. My configuration is the following:
persistence.xml
...
<!-- Configuring Eclipse Link -->
<property name="javax.persistence.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:jtds:sqlserver://SERVER/dev;instance=MSSQL2008R2"/>
<property name="javax.persistence.jdbc.user" value="user"/>
<property name="javax.persistence.jdbc.password" value="password"/>
<property name="eclipselink.persistence-context.flush-mode" value="commit" /> <!-- Flushing occurs at transaction commit. (https://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/p_persistence_context_flushmode.htm)-->
<!-- We use the EclipseLink internal components (https://www.eclipse.org/eclipselink/documentation/2.6/jpa/extensions/persistenceproperties_ref.htm)-->
<!-- Eclipselink jdbc configuration -->
<property name="eclipselink.jdbc.batch-writing" value="JDBC"/> <!-- Batch-writing is supported by mssql and our jdbc driver (https://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/p_jdbc_batchwriting.htm) -->
<!-- <property name="eclipselink.jdbc.batch-writing.size" value="10000"/> --> <!--Performance testing http://java-persistence-performance.blogspot.ch/2013/05/batch-writing-and-dynamic-vs.html -->
<property name="eclipselink.jdbc.bind-parameters" value="true"/> <!-- Parameterized sql queries -->
<property name="eclipselink.jdbc.cache-statements" value="true"/> <!-- https://docs.oracle.com/middleware/1212/core/ASPER/toplink.htm#ASPER99838 -->
<property name="eclipselink.jdbc.cache-statements.size" value="10000"/>
<property name="eclipselink.jdbc.allow-native-sql-queries" value="false"/> <!-- We explicitly set this, even though it is disabled by multitenancy by default -->
<!-- Eclipselink connection pool configuration-->
<property name="eclipselink.connection-pool.default.initial" value="50" />
<property name="eclipselink.connection-pool.default.min" value="50"/>
<property name="eclipselink.connection-pool.default.max" value="100"/>
<property name="eclipselink.connection-pool.default.url" value="jdbc:jtds:sqlserver://SERVER/dev;instance=MSSQL2008R2"/>
<!-- Eclipselink cache configuration -->
<property name="eclipselink.cache.shared.default" value="true" />
<!-- Eclipselink logging configuration -->
<property name="eclipselink.logging.level" value="OFF"/> <!-- How much log should be shown | from: https://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging#Log_Level_Configuration-->
<property name="eclipselink.logging.level.sql" value="OFF"/> <!-- How to show the sql queries -->
<property name="eclipselink.target-database" value="SQLServer"/> <!-- What sql database is used | from: http://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/p_target_database.htm-->
<property name="eclipselink.ddl-generation" value="none"/>
<property name="eclipselink.session.customizer" value="platform.data.EclipseLinkSessionCustomizer"/> <!-- Defines a naming strategy -->
<property name="eclipselink.multitenant.tenants-share-emf" value="false"/>
...
Thank you for your help!

Related

Configuring the WSO2 IS to external LDAP

I've been following this documentation on how to connect to external LDAP server from WSO2 Identity Server.
Now I am stuck at running the product. Upon running the WSO2 IS, I got an error saying that the admin user is not exist in PRIMARY. If I am using the existing configuration, everything went well. So i thought, this might be because of the configuration that I make at the user-mgt.xml and tenant-mgt.xml
This is my external LDAP configuration:
LDAP User and Group
This is my user-mgt.xml file looks like
<UserManager>
<Realm>
<Configuration>
<AddAdmin>true</AddAdmin>
<AdminRole>admin</AdminRole>
<AdminUser>
<UserName>admin</UserName>
<Password>*****</Password>
</AdminUser>
<EveryOneRoleName>everyone</EveryOneRoleName> <!-- By default users in this role sees the registry root -->
<Property name="isCascadeDeleteEnabled">true</Property>
<Property name="initializeNewClaimManager">true</Property>
<Property name="dataSource">jdbc/WSO2CarbonDB</Property>
</Configuration>
<UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ConnectionURL">ldap://10.251.45.200:389</Property>
<Property name="ConnectionName">cn=ldap,dc=ei,dc=local</Property>
<Property name="ConnectionPassword">P#ssw0rd</Property>
<Property name="AnonymousBind">false</Property>
<Property name="UserSearchBase">ou=People,dc=ei,dc=local</Property>
<Property name="UserEntryObjectClass">identityPerson</Property>
<Property name="UserNameAttribute">uid</Property>
<Property name="UserNameSearchFilter">(&(objectClass=person)(uid=?))</Property>
<Property name="UserNameListFilter">(objectClass=person)</Property>
<Property name="DisplayNameAttribute"/>
<Property name="ReadGroups">true</Property>
<Property name="WriteGroups">true</Property>
<Property name="GroupSearchBase">ou=Group,dc=ei,dc=local</Property>
<Property name="GroupEntryObjectClass">groupOfNames</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="GroupNameSearchFilter">(&(objectClass=groupOfNames)(cn=?))</Property>
<Property name="GroupNameListFilter">(objectClass=groupOfNames)</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="SCIMEnabled">true</Property>
<Property name="IsBulkImportSupported">false</Property>
<Property name="EmptyRolesAllowed">false</Property>
</UserStoreManager>
</Realm>
Please help me here, I so stuck at this process. Any advice would be great !

Multiple Persistence Store for Apache Ignite

I have one use case where I have to support multiple persistence store for my ignite cluster,For example Cache A1 should be primed from Database db1 and Cache B1 should be primed from database db2. can this be done?.In ignite Configuration XML I can only provide one persistence store details,
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<!-- Datasource for Persistence. -->
<bean name="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:#localhost:1521:roc12c" />
<property name="username" value="test" />
<property name="password" value="test" />
</bean>
In my CacheStore implementation I can only access this Database right?.
I've not tried this, but if its similar to other bean-configured systems. You should be able to create another bean with a different name and configuration. Then in your cache configuration for A1 and B1 specify the different data sources. That being said, I'm guessing that theoretically.
It may be that you are already doing so, but I can't tell from your question. If you instead choose to implement your caches in this manner https://apacheignite.readme.io/docs/persistent-store you can definitely configure two caches to have different data sources. This is how I'm currently implementing multiple caches. In the cache store I use I specifically call out which database to go to.
Here is a cache configuration I use for mine.
<property name="cacheConfiguration">
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<!-- Set a cache name. -->
<property name="name" value="recordData"/>
<property name="rebalanceMode" value="ASYNC"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="backups" value="1"/>
<!-- Enable Off-Heap memory with max size of 10 Gigabytes (0 for unlimited). -->
<property name="memoryMode" value="OFFHEAP_TIERED"/>
<property name="offHeapMaxMemory" value="0"/>
<property name="swapEnabled" value="false"/>
<property name="cacheStoreFactory">
<bean class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
<constructor-arg value="com.company.util.MyDataStore"/>
</bean>
</property>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
</bean>
</property>
Cache store is configured per cache, so you just need to inject different data sources to different stores. What you showed is just a standalone data source bean, it's not even a part of IgniteConfiguration. You can have multiple data source beans with different IDs.

Is it possible to generate artifacts for all the tables at once with MyBatis Generator?

I am using MyBatis Generator 1.3.1 from the command-line. I read in the documentation that I need to specify at least one table for object generation, but I was hoping maybe it is possible to use some wildcard and have mappers for all the tables generated at once? We don't want to use Hibernate, because MyBatis seems to handle custom types in the database better.
Thank you for your help!
You can use SQL wildcards, ie:
<table tableName="%">
<property name="useActualColumnNames" value="true"/>
</table>
You can reference: link
If you use MySQL, The crucial point is this:
<table schema="dbName" tableName="%"</table> and
<property name="nullCatalogMeansCurrent" value="true" />
reference:http://www.mybatis.org/generator/usage/intro.html
Settings like this:
<generatorConfiguration>
<properties resource="mybatis-generator/generator.properties"></properties>
<classPathEntry location="${driverLocation}"/>
<context id="default" targetRuntime="MyBatis3">
<property name="javaFileEncoding" value="UTF-8"/>
<commentGenerator type="org.zhang.generator.MyCommentGenerator">
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<jdbcConnection
driverClass="${driverClassName}"
connectionURL="${url}"
userId="${username}"
password="${password}">
<property name="nullCatalogMeansCurrent" value="true" />
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="true"/>
</javaTypeResolver>
<javaModelGenerator targetPackage="com.entity" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="daoMappers" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<javaClientGenerator targetPackage="com.dao" targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table schema="dbName" tableName="%"
enableSelectByPrimaryKey="true"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
enableDeleteByPrimaryKey="false"
enableUpdateByPrimaryKey="false"
enableInsert="false">
<property name="useActualColumnNames" value="true"></property>
</table>
</generatorConfiguration>

Inject Weblogic JDBC datasource (JNDI name) in spring applicationContext.xml

Currently, I am creating dataSource in spring applicationContext.xml by reading DB credentials from a property file.
<!-- property config -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"><value>/WEBINF/resources/springConfig.properties</value></property>
</bean>
<!-- Database connection Oracle 10g jdbc -->
<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
<property name="URL" value="${url}" />
<property name="user" value="${user}" />
<property name="password" value="${password}" />
<property name="connectionCachingEnabled" value="true" />
</bean>
Then i am referencing it using context.getBean
DataSource dataSource = (DataSource)context.getBean("dataSource");
I need to modify my applicationContext to create dataSource by not reading a property file but by using Weblogic JDBC datasource (I am not sure if its jndiTemplate or jdbcTemplate)
Please provide an example and do i need to change the way i do getBean("dataSource") once i use the jndiTemplate?
You want to do a JNDI datasource lookup. Here's an example:
http://middlewaremagic.com/weblogic/?p=5106

How to Configure SSL over Database in Spring?

I want to add SSL security in the Database layer. I am using Struts2.1.6, Spring 2.5, JBOSS 5.0 and Informix 11.5. Any idea how to do this?
I have researched through a lot on the internet but could not find any solution.
Please suggest!
Here is my datasource and entity manager beans which is working perfect without SSL:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="INFORMIX" />
<property name="showSql" value="true" />
</bean>
</property>
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.informix.jdbc.IfxDriver" />
<property name="url"
value="jdbc:informix-sqli://SERVER_NAME:9088/DB_NAME:INFORMIXSERVER=SERVER_NAME;DELIMIDENT=y;" />
<property name="username" value="username" />
<property name="password" value="password" />
<property name="minIdle" value="2" />
</bean>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" lazy-init="false">
<property name="targetObject" ref="dataSource" />
<property name="targetMethod" value="addConnectionProperty" />
<property name="arguments">
<list>
<value>characterEncoding</value>
<value>UTF-8</value>
</list>
</property>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" scope="prototype">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
Thankyou very much for your suggestion. So basically I need to set something like this in my applicationContext.xml, Please correct me if I am wrong:
<property name="username" value="username" />
<property name="password" value="password" />
**<property name="sslConnection" value="true" />**
<property name="minIdle" value="2" />
But how do I set the SSL certificate in java runtime. The link which you have provided is good but for some reason I am not able to follow. Please put your suggestion.
Using SSL for the communication between an application and a database is something that has to be supported by the database server (and the JDBC driver).
According to the documentation, this is supported by Informix Dynamic Server (IDS) since version 11.50.
You can use SSL support in your Java applications if you use IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to DB2® for z/OS® Version 9 or later, to DB2 Database for Linux®, UNIX®, and Windows® Version 9.1, Fix Pack 2 or later, or to IBM Informix® Dynamic Server (IDS) Version 11.50 or later.
(...)
To use SSL connections, you need to:
Configure connections to the data source to use SSL. (link)
Configure your Java Runtime Environment to use SSL. (link)
The documentation should help.
If you're using a version of IDS prior to 11.50, then I'm afraid you'll have to use SSH tunneling.