Best way for encapsulating the oracle and mysql [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have many kinds of db, some are oracle and some are MySQL ,
so when i have an operation about transaction , how can i know which db should be operated.
Have the ways to encapsulate for them to ensure the correct operation ?
what should i do to route these transaction to the correct db ? Do you have any ideas?

Database portability is a great goal to aim for, and is fully achievable for standard & even moderately complex business applications.
Practically, there are two main issues:
1) Some databases (Oracle) have non-standard DDL, especially data-types. This can be converted easily, with search-and-replace.
2) ID/ primary key generation has to be portable; this rules out sequences & auto-generated columns. Use an allocator table instead, which can be completely portable as well as significantly more performant.
Using a persistence layer (such as Hibernate) helps insulate over a few other differences. I've had very good success making even major & complex applications, coming from a major migration and re-engineering project, portable from Oracle to MySQL.

Related

can i build a java desktop application without sql knoledge [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
i am not a pro with programming, and i'm trying to build a desktop app with java, but i need to combine it with sql in order to store a lot of info in a table (database..)
and when i googled i found hours of tutorials to learn sql,
i'm still struggling with java and i have no time to deal with sql too...
can i do this without learn the sql language and all...?
do i have to sit down and study it all or is there another way around?
(p.s. sorry, i think my english not that good...)
Well there's some options:
Use files instead of a database. You can make use of serialization to store your instances directly on files.
Use a non relational database so you won't have to deal with learning SQL
Use an SQL database but search for an ORM. ORMs let you interact with relational databases without typing SQL directly (but you can if you need to when necessary)

JOOQ vs Hibernate [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
When I chat to stackoverflowers on chat and read other tutorials about database with Java then they are guide me to use JOOQ instead of HIBERNATE.
I am totally aware about ORM with Hibernate and I prefer to use Hibernate and now aware almost about JOOQ by reading tutorials and implementation on small projects.
But I am confused what to choose and what is perfact for my dynamic web-applications which can be larger,medium or smaller, either Hibernate or JOOQ ?
BTW googled a lot but confused more and more...!!!
Just Like : this,this and this.
Which one is best for different conditions and situations for developer.?
While jOOQ and Hibernate compete for the same target audience, they do not solve the same problem at all. You've already linked this article in your question. The essence of it is simple:
Are you going to solve object graph persistence problems? Use an ORM (e.g. Hibernate)
Are you going to embed SQL into Java? Use SQL (e.g. jOOQ)
Of course, since both APIs cover accessing relational databases, they overlap in functionality to a certain extent. E.g. Hibernate also supports simple querying, while jOOQ also supports simple mapping.
While we should avoid delving into subjective discussions about whether object graph persistence or SQL is a better approach at interacting with your database, I think the above is a pretty objective answer to what API is better suited, once you've made the subjective decision.
AND: You can use both, e.g. ORM/Hibernate for CRUD, SQL/jOOQ for reporting.
(Disclaimer: I work for the company behind jOOQ, so this answer is biased)

What changes should be made to a web application from MySQL to MariaDB? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have a web application developed with Java (JSP, Servlets, etc) where I use MySQL as DBMS, take care:
Connection Pool
PreparedStatement
Stored Procedures
-Triggers
My question is how many changes I have to make my application (In addition to changing the name of the driver and the. Jar) for smooth functions with MariaDB.?
Or what considerations should I take for that change?
There is a compability list on MariaDBs pages so you can see that 99% is the same like in MySQL. And from Java perspective, your statements and connection pool should remain the same, however I suppose they can be minor changes in a way how to write stored procedures.
So generally, this transition shouldn't cause any problems but you still want to test this thoroughly in order to be sure that nothing really changed.
MariaDB is a direct fork of the MySQL codebase which hasn't diverged much from it yet. The developers are doing their best to avoid any compatibility-breaking changes to make sure that MariaDB can be used as a drop-in replacement for MySQL. That means switching from MySQL to MariaDB is comparable with updating your MySQL version.
It is unlikely that you will have to make any modifications at your application at all. Still, a proper integration test is definitely in order before migrating the production system, especially when your MySQL version isn't up-to-date.

what approach should I take in heavy iterations? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I got this Java webapp (JSP+Struts+Hibernate+MySQL+tomcat6) in which there are like 20000 users right now and the number is growing up rapidly. I have to rank all the users periodically. The ranking process involves lots of objects and hibernate actions and it's fairly heavy. Talking java, unfortunately I must iterate on all of the users and apply this procedure in them one by one. this method sucks out lots of the server's resources.
on the other hand I might be able to run all these actions in a stored procedure on the MySQL side. I'm pretty sure the code there will be a complete mess and troublesome to modify later on. although the performance would be much more better this way but software engineering principles wouldn't take this solution nicely.
what do you suggest?
This is obviously much more efficient in SQL. The real problem is that you are using hibernate and so have lost control over your schema which is why a solution like iBatis, although less popular, makes more sense - because it allows you to switch to SQL when that is the more appropriate tool for the job.
Given that you have chosen hibernate, are you sure that you can't push the API it provides into doing this? Have you looked in detail at the criteria API? That includes associations - it might be possible to shoe-horn what you want in there and so keep the logic more closely associated with the classes. http://docs.jboss.org/hibernate/stable/core/reference/en-US/html/querycriteria.html

Easiest way of getting third party database information into java objects [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am making some small "business intelligence" applications/tools that need to talk to other systems. Primarily accounting systems that believe that databases are an integration layer (or are too lazy to provide an api).
What's the easiest way of getting specific data out of a third party database and into my Java objects?
Notes:
(I am now bolding the points below that have not been directly answered)
This is absolutely a read only situation. I would prefer a solution that cannot write.
Depending on speed and/or aggregation requirements, I may want/need to store these records at a future point. (This may or may not impact on solutions like hibernate which would have difficulty reading from one db and writing to another)
The first cut would be a very select partial object population (I have generated my objects from an xml schema, and the database will only need to supply 30% of the possible fields etc)
The first db integration target is (Visual?)FoxPro - hence point 2.
I am currently developing primarily in Java, but expect that to change to scala soonish (can LINQ help here?)
The standard of mapping db schema to objects (and vice versa) is the Java Persistence API. There are several implementation like Hibernate and EclipseLink (and others). I can't tell for all of them, but hibernate an eclipse plugin called hibernate tools, which can generate Java classes from the schema. You can find instructions here
JPA has its own query language called JPQL, Hibernate supports an extended version of it called HQL. Both looks like SQL, applied to objects.
I suggest you take a look at ScalaQuery, if you are doing Scala code.

Categories