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.
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.
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
I wonder the simplicity of working with Microsoft SQL database server with .NET Entity Framework. Is there a possible way to use it with Oracle & MySQL database servers?
You could use another ORM, like NHibernate which supports Microsoft SQL, Oracle, and MySQL, among many others.
If you want/need to stick with EF, there are already questions on SO about using it with MySQL and with Oracle.
Oracle Data Access Components for .NET (http://www.oracle.com/technetwork/topics/dotnet/downloads/oracleefbeta-302521.html) includes also Oracle Data Provider for .NET 4 11.2.0.2.40.
A nice tutorial how to use Model-First approach can be found at http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/EntityFrameworkOBE/EntityFrameworkOBE.htm.
Good luck,
LM
A list of Oracle providers for Entity Framework can be found here:
Comparison of Entity Framework compatible providers for Oracle?
And for MySQL these are available:
http://www.mysql.com/products/connector/
http://www.devart.com/dotconnect/entityframework.html
http://uda.openlinksw.com/dotnet/
i was asked to do a book manager at university with hibernate and mysql. I have a simple question. If i choose to do a web application, grails already uses hibernate. GORM runns over hibernate. so to use mysql i only need to configure jdbc grails drivers and that's it?
i mean, "for the project you must use hibernate and mysql" - this are the requirements. So can i do that way?
thanks in advance,
JM
Yes, of course you can.
You'll need to get the MySQL JDBC driver from this location.
Grails? When you're new to programming? Whose idea was this?
Personally, I think that taking on all these unknowns is risky for someone who's "new to programming." Do you know anything about SQL or JDBC? Have you ever written a web project before? This could be difficult.
I don't know how to be more specific. Download the JDBC JAR from the link I gave you.
I'd recommend that you start with a JDBC tutorial first. Hibernate is not for you - yet.
Hibernate is an object-relational mapping tool (ORM). It's a technology that lets you associate information in relational database tables to objects in your middle tier. So if you have a PERSON table with columns id, first, and last Hibernate will let you associate those data with the private data members in your Person Java class.
That sounds easy, but it gets complicated quickly. Your relational and object models might have one-to-many and many-to-many relationships; Hibernate can help with those. Lazy loading, caching, etc. can be managed by Hibernate.
But it comes at a cost. And it can be difficult if you aren't familiar with it.
If you have a deadline, I'd recommend creating a Java POJO interface for your persistence classes and doing the first implementation using JDBC. If you want to swap it out for Hibernate later on you can do it without affecting clients, but you'll have a chance of making progress without Hibernate that way.
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.