Java Magazine, May/June 2016
ORACLE COM JAVAMAGAZINE MAY JUNE 2016 30 big data When it comes to handling big data in applications there are several pitfalls to avoid An application that runs perfectly fine on a small or medium size database can fail once the database has increased in size Failure points for applications working with large amounts of data can encompass a broad spectrum of areas including memory poor database transaction performance and bad architecture Whether your development team chooses to use JDBC or an objectrelational mapping framework the architecture of your application can mean the diference between success and failure In this article I cover some best practices to be used for working with data via JDBC or the Java Persistence API JPA so that your application does not fail under the pressure of big data I dont delve into any proprietary APIs or frameworks for working with big data or target any particular database options available via standard RDBMS or NoSQL Rather I provide basic strategies for configuring environments and tuning code as well as best practices for working with large amounts of data via a Java application First Things First Stored Procedures Ask yourself this question Why am I pulling this large amount of data into my application If the answer is that you are trying to perform some calculations analysis or other processing on a very large result set you might want to reconsider your technique Most databases specifically RDBMSs contain a variety of built in functions and procedures for performing processing of data directly within the database whereas many NoSQL databases dont ofer stored procedures However many NoSQL databases offer some type of function or stored code capability although theyre not often as capable as those offered by a standard database Many database solutions also contain a language that enables you to develop procedures that can be executed directly within the database For example Oracle Database contains its own procedural language known as PL SQL which safely extends the SQL language When working with big data you can achieve huge performance gains by allowing the database rather than the application to perform analytical processing unless of course there is an analytical processing requirement that can only be performed outside of the database The JDBC API and JPA both contain solutions for calling upon a databases stored procedures Its also easy to pass or retrieve values with stored procedures and the best part is that a single connection can be made to call upon the procedure which can in turn process thousands of records Listing 1 demonstrates how to call a database stored procedure using either JDBC or JPA Listing 1 Using JDBC to call upon a database stored procedure JOSH JUNEAU Big Data Best Practices for JDBC and JPA Focus on the fundamentals so youre not overwhelmed by large amounts of data
You must have JavaScript enabled to view digital editions.