In the past, I integrated reactive spring data with mongoDb and everything gone fine.
Now I want the same non blocking access using mysql, but i didnt find any article about it.
I wish to use a mature and standard spring library, if you know one, please share it to me.
What you are looking for is R2DBC and Spring Data R2DBC.
R2DBC is a reactive alternative to JDBC.
And Spring Data R2DBC is a Spring Data module for it.
Since R2DBC is only a specification/API you also need a driver for the database of your choice. For MySql that would be https://github.com/jasync-sql/jasync-sql
Related
Recently, I started investigation of activiti framework to integrate it into my current project.
In our project we use teradata database.
So I added activiti dependency and created simple bpmn process for testing purposes.
I tested this process with h2 inmemory database and it worked fine.
But when configured project to use teradata I've got exception on spring boot application startup.
Caused by: org.activiti.engine.ActivitiException: couldn't deduct database type from database product name 'Teradata'
I have googled and found only this topic on internet space:
https://hub.alfresco.com/t5/alfresco-process-services/does-activiti-support-teradata-database/m-p/17587#M287
It seems there is no way to integrate activiti and teradata for now.
So the reason why I am here posting this question is that I just want to make sure there is no way to reach integration between those technologies.
Any suggestions and ideas will be welcomed. Thank you.
Activiti is an open source product and can be "adapted" to almost any back end transactional database. Transaction support is a must as any BPMN engine is basically a state machine.
Database access is isolated in the entity layer and specific SQL is managed by the Ibatis ORM.
To integrate a specific database, you will need to modify the entity and ORM layers.
Certainly possible and actually not that much work (typically about 30 hours in my experience), but it is work you have to do and maintain yourself.
We would like to support two databases MySQL and Cassandra to our application. Our application will be built using Spring. I would to like to have common entities which has to be shared by both MySQL and Cassandra I would like to change the DB dynamically based on customer preference. How can I achieve this
If your requirements to have the system runnable on both data stores, with only one at a time, this I think it is achievable.
The following advices i believe will let you achieve this but i didn't try'em: (supposing that you uses spring-boot)
In maven put the dependency for spring data jpa and spring data mongo.
Enable both jpa and mongo repositories (see EnableJpaRepositoies)
On entities put both JPA and Mongo annotations.
Use PagingAndSortingRepository as base interface for you repositories
In application.properties either configure mysql or mongo db through spring boot well-defined properties
This might work in regular spring apps but will need modifications; also include corresponding driver dependencies in pom file.
Edit: you can use 'spring.data.jpa.repositories.enabled=false' ( and its mongo counterpart) source: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java
I have a spring project configured to use MySql database. Is is possible to implement elasticsearch for some search queries? Does anyone has a relevant experience or can point me to a good article?
You can easily use Spring Data for Elasticsearch without having much Elasticsearch knowledge. Take a look at the toy project here.
Spring Data will help you on doing CRUD operations with an ORM approach.
I have done some research but I haven't come to a final conclusion yet.
What is the best way to connect to MySQL DB when having Spring MVC + tomcat?
Is it Hibernate, JPA, JDBC or Hibernate/JPA?
Thanks,
Sara.
JPA is more like a standard. Hibernate is an implementation of the JPA, which means Hibernate is one possible way of using JPA for database connection.
Eclipselink is an other popular implementation of JPA. (Earlier versions of Hibernate was not JPA, but you'll probably do not want to use pre-JPA Hibernate.)
So these would be the options:
Hibernate/JPA
Eclipselink/JPA
JDBC
JDBC is a low-level approach, it is much more troublesome to use it but also more felxible and sometimes you can achieve better performance with it. I'd drop JDBC until you have such problems that cannot be solved with JPA.
It is hard to choose between Hibernate and other JPA implementations unless you provide more details about your project. One thing is sure, Hibernate is popular (here on SO as well) and you'll be able to get help if you get stuck on a specific issue.
I suggest to go for Hibernate/JPA.
Unable to determine what is the best way to connect to mysql database in struts..
We can always use DriverManger and Class.forName() to connect.
DataSource interface - but this has problems I am getting compliation error for
DataSource dataSource = (DataSource)context.getAttribute(Globals.DATA_SOURCE_KEY);
or when Action.Data_SOURCE_KEY is used. when searched I found that these variables are depricated.
How can I use connection pooling in struts?What is best place to place url,username,pass for database?DO i still have to use datasource configuration in same way in struts-config? Then why was this facility depricated?
Too many queastions but I cannot find a definite source to learn struts.
Struts doc can be but then revisions and backword compatibility are the issues which a learner cannot get easily... Pls suggest a good source to learn struts2.
Struts is an MVC framework, not a database access framework. You should use some sort tool for your Data Access Layer. Spring makes it really easy to manage connections, transactions, and the sort, and integrates well with ORM tools like Hibernate or the JPA implementation.
Where Struts fits in in this is that it will manage the request, delegate to an action, which in turn will invoke a service that uses your data access layer. You could put your DAL in your actions, but I wouldn't -- I would put them in a service.
Struts is a framework having the MVC approach. It makes you to create application in an efficient way. Connection between database is somewhat risk compare to someother connection.