SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
Midao
DATA ORIENTED UMBRELLA PROJECT
Midao Project
◦ What is it ?
◦ Midao is a Project which unites few data oriented projects under it's umbrella.
◦ Write once – execute everywhere ?
◦ Not really. Current world is all about information. Amount of tools to work with it grows very quickly, as infrastructure and complexity along
with it. Amount of development and support for such systems increases because of it's diversity and complexity. Midao was created to
simplify all that.
◦ When it would be released ?
◦ Midao JDBC was already released. Next libraries will be released as soon as they are ready (current deadline is end of 2014 – 2015)
◦ Why it takes so long ?
◦ Midao suppose to be next generation libraries which simplify development for different storage applications, improve portability, provide
single API for different databases, offer additional features (not provided by drivers) and, most importantly, is event based and simple to use.
It is a lot of work (due to lack of standards and different feature sets) and I am planning to invest as much time as needed in order to create
quality libraries worth using.
◦ What would be supported ?
◦ Goal is to provide support for as much data sources as possible.
◦ Which languages are supported ?
◦ Midao is developed using Java. In future, native support of other languages is possible.
◦ Which license is used ?
◦ Apache License Version 2.0.
ETA 2015
End of 2014
ETA 2015
Released
Midao components
Simplifies work with local/remote
data/file storage systems.
Simplifies work with distributed
cache/data grid systems.
Simplifies work with document
oriented databases (including but not
limited to NoSQL databases).
Simplifies work with relational databases
using Java JDBC.
Midao
JDBC
Midao
DOD*
Midao
File*
Midao
VOS*
Midao
Integration
* - those are code names and are subject to change
Midao JDBC
◦ What is it ?
◦ Midao JDBC is part of Midao Project. It is created to provide support for RDBMS Databases using JDBC driver.
◦ Write once – execute everywhere ?
◦ Not completely. Goal is to simplify: it hides complexity/nuances of vendor JDBC drivers, makes work with JDBC more comfortable
and ensures good performance by utilizing best practices.
◦ When can I use it ?
◦ You can start playing with it right now, but it is not ready for use in Production yet. Final release is planned in Autumn.
◦ What future holds ?
◦ List of features to be implemented is not small. Please visit http://midao.org/status.html details.
Why Midao JDBC ?
◦ It simplifies work with JDBC.
◦ Transactions, metadata, type handling, input/output processing, cached/lazy queries, named parameters etc.
◦ It simplifies work with vendor JDBC driver implementation.
◦ Supports Oracle Database, Microsoft SQL, Oracle MySQL, MariaDB, PostgreSQL etc.
◦ Vendor specific type handling/metadata/exception handling.
◦ It handles resources and provides best practices for you.
◦ Library ensures that all resources are used no longer than needed and are closed properly. Also it utilizes best practices while
working with JDBC Drivers.
◦ It provides additional functions for you.
◦ Profiling, Pooled Data Sources, Lazy query execution support.
◦ And with all of the above - it is still small and simple to use library.
What about others
◦ Midao JDBC vs Spring JDBC*.
◦ Smaller, simpler and little more customizable/extensible.
◦ Provides additional functionality not present in Spring JDBC.
◦ Doesn't require Spring container to work.
◦ Provides some support for Spring JDBC (templates, exception handlers, metadata).
◦ Apache DbUtils*.
◦ Handles much more JDBC boilerplate code.
◦ Provides much more functionality.
◦ Configurable/extensible.
◦ Midao JDBC follows principles set by DbUtils. Which results in easier migration and short learning curve for Apache DbUtils
projects.
◦ Midao JDBC vs Hibernate(and other ORM Libraries/Frameworks).
◦ Smaller and have better performance(because of direct JDBC usage).
◦ Midao JDBC is not an ORM Library/Framework nor tries to be one. It's main goal to work with SQL directly while providing
functionality to make it more comfortable to use object relational mapping when needed.
* - Migration Guide, with those points explained, due to lack of time - is currently on hold. If you have time to write one – please contact me (look feedback slide)
Start using
How to start ?
DownloadGrab midao-core-jdbc.jar at midao.org
Maven
Add Maven dependency:
• Dependencies:
• No mandatory dependencies.
• SLF4j is optional dependency and can be used if present.
• Support:
• Java 5&6.
• JDBC3&JDBC4.
<dependency>
<groupId>org.midao</groupId>
<artifactId>midao-jdbc-core</artifactId>
<version>0.9.4</version>
</dependency>
Often less is better
• At beginning focus on Query runner and Input/Output handlers.
• As you progress you might be interested in Type handlers, Pooled data sources, Transactions, Lazy
output handlers, Profiling and configuration of library.
• When you will arrive to the point when you think you want to improve it – it is worth looking at
Metadata handlers, Statement handlers and Exception handlers.
Assumptions
Before we start you need to set up your environment.
In below examples we assume that:
1. JDBC drivers were added to project Classpath via Eclipse or Maven/Ant.
2. You have SQL Connection received from DataSource or DriverManager.
3. Midao JDBC Core was added to project Classpath via Eclipse or Maven/Ant.
For full examples please consider viewing:
1. http://midao.org/home.html#examples
2. https://github.com/pryzach/midao/tree/master/midao-jdbc-examples/src/main/java/org/midao/jdbc/examples
Query runner, transactions and profiling
All queries are executed via Query Runner. In order to receive Query Runner instance Factory
can be used:
After runner instance is received – queries can be executed via:
Transactions are handled automatically by library (using auto-commit mode), but if you are
interested in manual handling you can do:
Profiling is switched off by default. In order to switch it on:
QueryRunnerService runner = MjdbcFactory.getQueryRunner(conn);
runner.batch()/runner.query()/runner.update()/runner.call();
runner.setTransactionManualMode(true);
...
runner.commit()/runner.rollback();
MjdbcConfig.setProfilerEnabled(true);
Input and Output handlers
Input handlers are responsible for handling query input: (named) SQL string and input
parameters:
Output handlers are responsible for handling query output (ResultSets):
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("id", 1);
MapInputHandler input = new MapInputHandler(
"SELECT name FROM students WHERE id = :id", queryParameters);
Map<String, Object> result = runner.query(input, new MapOutputHandler());
System.out.println("Query output: " + result.get(“name”));
Hello World JDBC style
QueryRunnerService runner = MjdbcFactory.getQueryRunner(conn);
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("id", 1);
MapInputHandler input = new MapInputHandler(
"SELECT name FROM students WHERE id = :id", queryParameters);
Map<String, Object> result = runner.query(input, new MapOutputHandler());
QueryRunnerService runner = MjdbcFactory.getQueryRunner(conn);
BeanInputHandler<Student> input = null;
Student student = new Student();
student.setId(2);
// :id is IN parameter and :name and :address are OUT parameters
input = new BeanInputHandler<Student>("{call TEST_NAMED(:id, :name, :address)}", student);
// result would be filled student object searched by ID = 2. All values would come from OUT param.
Student result = runner.call(input);
Mapinput
example
Beaninput
example
What’s next ?
◦ Visit http://www.midao.org/
◦ Browse Midao JDBC code on GitHub.
◦ Browse Midao JDBC JavaDoc.
◦ Read getting started guide www.midao.org/mjdbc-getting-started.html
◦ Follow us on Freecode midao.
Feedback, suggestions and questions
◦ stackoverflow.com still is the best place to start asking questions.
◦ Java Ranch (JDBC forum) is monitored for questions related to Midao JDBC.
◦ Mailing lists can be used: questions@midao.org
◦ midao.org have feedback section(below) where you can provide one.
◦ And if everything else fails - you can always contact me directly:
pryzach@gmail.com.
Wow, you are still reading ?
Hope this library would be useful for you.
THANK YOU

Weitere ähnliche Inhalte

Was ist angesagt?

Java Lesson English
Java Lesson EnglishJava Lesson English
Java Lesson English
erdensaihana
 

Was ist angesagt? (20)

Java script framework
Java script frameworkJava script framework
Java script framework
 
MongoDB - A next-generation database that lets you create applications never ...
MongoDB - A next-generation database that lets you create applications never ...MongoDB - A next-generation database that lets you create applications never ...
MongoDB - A next-generation database that lets you create applications never ...
 
Odi best-practice-data-warehouse-168255
Odi best-practice-data-warehouse-168255Odi best-practice-data-warehouse-168255
Odi best-practice-data-warehouse-168255
 
Odi interview questions
Odi interview questionsOdi interview questions
Odi interview questions
 
DotNetToscana: NoSQL Revolution - RavenDB
DotNetToscana: NoSQL Revolution - RavenDBDotNetToscana: NoSQL Revolution - RavenDB
DotNetToscana: NoSQL Revolution - RavenDB
 
Polyglot Persistence
Polyglot Persistence Polyglot Persistence
Polyglot Persistence
 
3 jdbc
3 jdbc3 jdbc
3 jdbc
 
SQL vs NoSQL: Big Data Adoption & Success in the Enterprise
SQL vs NoSQL: Big Data Adoption & Success in the EnterpriseSQL vs NoSQL: Big Data Adoption & Success in the Enterprise
SQL vs NoSQL: Big Data Adoption & Success in the Enterprise
 
Enterprise-class security with PostgreSQL - 1
Enterprise-class security with PostgreSQL - 1Enterprise-class security with PostgreSQL - 1
Enterprise-class security with PostgreSQL - 1
 
Tips and Tricks of Toad for Oracle 10.6
Tips and Tricks of Toad for Oracle 10.6Tips and Tricks of Toad for Oracle 10.6
Tips and Tricks of Toad for Oracle 10.6
 
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaSQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview Questions
 
Oracle Exadata Interview Questions and Answers
Oracle Exadata Interview Questions and AnswersOracle Exadata Interview Questions and Answers
Oracle Exadata Interview Questions and Answers
 
CORE JAVA & ADVANCE JAVA
CORE JAVA & ADVANCE JAVACORE JAVA & ADVANCE JAVA
CORE JAVA & ADVANCE JAVA
 
Cause 2013: A Flexible Approach to Creating an Enterprise Directory
Cause 2013: A Flexible Approach to Creating an Enterprise DirectoryCause 2013: A Flexible Approach to Creating an Enterprise Directory
Cause 2013: A Flexible Approach to Creating an Enterprise Directory
 
CORE JAVA & ADVANCE JAVA
CORE JAVA & ADVANCE JAVACORE JAVA & ADVANCE JAVA
CORE JAVA & ADVANCE JAVA
 
Java Lesson English
Java Lesson EnglishJava Lesson English
Java Lesson English
 
Comparison between rdbms and nosql
Comparison between rdbms and nosqlComparison between rdbms and nosql
Comparison between rdbms and nosql
 
Odi 12c-getting-started-guide-2032250
Odi 12c-getting-started-guide-2032250Odi 12c-getting-started-guide-2032250
Odi 12c-getting-started-guide-2032250
 
What is MySQL? | MySQL Tutorial For Beginners | Creating Databases & Tables |...
What is MySQL? | MySQL Tutorial For Beginners | Creating Databases & Tables |...What is MySQL? | MySQL Tutorial For Beginners | Creating Databases & Tables |...
What is MySQL? | MySQL Tutorial For Beginners | Creating Databases & Tables |...
 

Andere mochten auch (8)

Kaizen lite
Kaizen liteKaizen lite
Kaizen lite
 
Aircraftpartsaopa 120913203925-phpapp01
Aircraftpartsaopa 120913203925-phpapp01Aircraftpartsaopa 120913203925-phpapp01
Aircraftpartsaopa 120913203925-phpapp01
 
2013 workforce conference powerpoint data update
2013 workforce conference powerpoint data update2013 workforce conference powerpoint data update
2013 workforce conference powerpoint data update
 
chocoYum: Taste-Testing the Mobile Landscape
chocoYum: Taste-Testing the Mobile LandscapechocoYum: Taste-Testing the Mobile Landscape
chocoYum: Taste-Testing the Mobile Landscape
 
ChocoYum: Taste-Testing The Mobile Advertising Landscape
ChocoYum: Taste-Testing The Mobile Advertising LandscapeChocoYum: Taste-Testing The Mobile Advertising Landscape
ChocoYum: Taste-Testing The Mobile Advertising Landscape
 
Spongebob
SpongebobSpongebob
Spongebob
 
Renewable and non renewable
Renewable and non renewableRenewable and non renewable
Renewable and non renewable
 
Noon Turf Care - Fall to Winter Lawn, Tree, Shrub, and Property Tips
Noon Turf Care - Fall to Winter Lawn, Tree, Shrub, and Property TipsNoon Turf Care - Fall to Winter Lawn, Tree, Shrub, and Property Tips
Noon Turf Care - Fall to Winter Lawn, Tree, Shrub, and Property Tips
 

Ähnlich wie Midao JDBC presentation

Ähnlich wie Midao JDBC presentation (20)

Java database programming with jdbc
Java database programming with jdbcJava database programming with jdbc
Java database programming with jdbc
 
JDBC
JDBCJDBC
JDBC
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
 
jdbc vs hibernate.pptx
jdbc vs hibernate.pptxjdbc vs hibernate.pptx
jdbc vs hibernate.pptx
 
Connect2014 Show104: Practical Java
Connect2014 Show104: Practical JavaConnect2014 Show104: Practical Java
Connect2014 Show104: Practical Java
 
Spring Data JPA
Spring Data JPASpring Data JPA
Spring Data JPA
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 
Choosing an IdM User Store technology
Choosing an IdM User Store technologyChoosing an IdM User Store technology
Choosing an IdM User Store technology
 
Dao example
Dao exampleDao example
Dao example
 
Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021
 
Managing Data in Jakarta EE Applications
Managing Data in Jakarta EE ApplicationsManaging Data in Jakarta EE Applications
Managing Data in Jakarta EE Applications
 
Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018
 
Jdbc
JdbcJdbc
Jdbc
 
java.pptx
java.pptxjava.pptx
java.pptx
 
SHOW104: Practical Java
SHOW104: Practical JavaSHOW104: Practical Java
SHOW104: Practical Java
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
 
web development 7.pptx
web development 7.pptxweb development 7.pptx
web development 7.pptx
 
Advanced JAVA
Advanced JAVAAdvanced JAVA
Advanced JAVA
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12
 
java 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptxjava 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptx
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Midao JDBC presentation

  • 2. Midao Project ◦ What is it ? ◦ Midao is a Project which unites few data oriented projects under it's umbrella. ◦ Write once – execute everywhere ? ◦ Not really. Current world is all about information. Amount of tools to work with it grows very quickly, as infrastructure and complexity along with it. Amount of development and support for such systems increases because of it's diversity and complexity. Midao was created to simplify all that. ◦ When it would be released ? ◦ Midao JDBC was already released. Next libraries will be released as soon as they are ready (current deadline is end of 2014 – 2015) ◦ Why it takes so long ? ◦ Midao suppose to be next generation libraries which simplify development for different storage applications, improve portability, provide single API for different databases, offer additional features (not provided by drivers) and, most importantly, is event based and simple to use. It is a lot of work (due to lack of standards and different feature sets) and I am planning to invest as much time as needed in order to create quality libraries worth using. ◦ What would be supported ? ◦ Goal is to provide support for as much data sources as possible. ◦ Which languages are supported ? ◦ Midao is developed using Java. In future, native support of other languages is possible. ◦ Which license is used ? ◦ Apache License Version 2.0.
  • 3. ETA 2015 End of 2014 ETA 2015 Released Midao components Simplifies work with local/remote data/file storage systems. Simplifies work with distributed cache/data grid systems. Simplifies work with document oriented databases (including but not limited to NoSQL databases). Simplifies work with relational databases using Java JDBC. Midao JDBC Midao DOD* Midao File* Midao VOS* Midao Integration * - those are code names and are subject to change
  • 4. Midao JDBC ◦ What is it ? ◦ Midao JDBC is part of Midao Project. It is created to provide support for RDBMS Databases using JDBC driver. ◦ Write once – execute everywhere ? ◦ Not completely. Goal is to simplify: it hides complexity/nuances of vendor JDBC drivers, makes work with JDBC more comfortable and ensures good performance by utilizing best practices. ◦ When can I use it ? ◦ You can start playing with it right now, but it is not ready for use in Production yet. Final release is planned in Autumn. ◦ What future holds ? ◦ List of features to be implemented is not small. Please visit http://midao.org/status.html details.
  • 5. Why Midao JDBC ? ◦ It simplifies work with JDBC. ◦ Transactions, metadata, type handling, input/output processing, cached/lazy queries, named parameters etc. ◦ It simplifies work with vendor JDBC driver implementation. ◦ Supports Oracle Database, Microsoft SQL, Oracle MySQL, MariaDB, PostgreSQL etc. ◦ Vendor specific type handling/metadata/exception handling. ◦ It handles resources and provides best practices for you. ◦ Library ensures that all resources are used no longer than needed and are closed properly. Also it utilizes best practices while working with JDBC Drivers. ◦ It provides additional functions for you. ◦ Profiling, Pooled Data Sources, Lazy query execution support. ◦ And with all of the above - it is still small and simple to use library.
  • 6. What about others ◦ Midao JDBC vs Spring JDBC*. ◦ Smaller, simpler and little more customizable/extensible. ◦ Provides additional functionality not present in Spring JDBC. ◦ Doesn't require Spring container to work. ◦ Provides some support for Spring JDBC (templates, exception handlers, metadata). ◦ Apache DbUtils*. ◦ Handles much more JDBC boilerplate code. ◦ Provides much more functionality. ◦ Configurable/extensible. ◦ Midao JDBC follows principles set by DbUtils. Which results in easier migration and short learning curve for Apache DbUtils projects. ◦ Midao JDBC vs Hibernate(and other ORM Libraries/Frameworks). ◦ Smaller and have better performance(because of direct JDBC usage). ◦ Midao JDBC is not an ORM Library/Framework nor tries to be one. It's main goal to work with SQL directly while providing functionality to make it more comfortable to use object relational mapping when needed. * - Migration Guide, with those points explained, due to lack of time - is currently on hold. If you have time to write one – please contact me (look feedback slide)
  • 8. How to start ? DownloadGrab midao-core-jdbc.jar at midao.org Maven Add Maven dependency: • Dependencies: • No mandatory dependencies. • SLF4j is optional dependency and can be used if present. • Support: • Java 5&6. • JDBC3&JDBC4. <dependency> <groupId>org.midao</groupId> <artifactId>midao-jdbc-core</artifactId> <version>0.9.4</version> </dependency>
  • 9. Often less is better • At beginning focus on Query runner and Input/Output handlers. • As you progress you might be interested in Type handlers, Pooled data sources, Transactions, Lazy output handlers, Profiling and configuration of library. • When you will arrive to the point when you think you want to improve it – it is worth looking at Metadata handlers, Statement handlers and Exception handlers.
  • 10. Assumptions Before we start you need to set up your environment. In below examples we assume that: 1. JDBC drivers were added to project Classpath via Eclipse or Maven/Ant. 2. You have SQL Connection received from DataSource or DriverManager. 3. Midao JDBC Core was added to project Classpath via Eclipse or Maven/Ant. For full examples please consider viewing: 1. http://midao.org/home.html#examples 2. https://github.com/pryzach/midao/tree/master/midao-jdbc-examples/src/main/java/org/midao/jdbc/examples
  • 11. Query runner, transactions and profiling All queries are executed via Query Runner. In order to receive Query Runner instance Factory can be used: After runner instance is received – queries can be executed via: Transactions are handled automatically by library (using auto-commit mode), but if you are interested in manual handling you can do: Profiling is switched off by default. In order to switch it on: QueryRunnerService runner = MjdbcFactory.getQueryRunner(conn); runner.batch()/runner.query()/runner.update()/runner.call(); runner.setTransactionManualMode(true); ... runner.commit()/runner.rollback(); MjdbcConfig.setProfilerEnabled(true);
  • 12. Input and Output handlers Input handlers are responsible for handling query input: (named) SQL string and input parameters: Output handlers are responsible for handling query output (ResultSets): Map<String, Object> queryParameters = new HashMap<String, Object>(); queryParameters.put("id", 1); MapInputHandler input = new MapInputHandler( "SELECT name FROM students WHERE id = :id", queryParameters); Map<String, Object> result = runner.query(input, new MapOutputHandler()); System.out.println("Query output: " + result.get(“name”));
  • 13. Hello World JDBC style QueryRunnerService runner = MjdbcFactory.getQueryRunner(conn); Map<String, Object> queryParameters = new HashMap<String, Object>(); queryParameters.put("id", 1); MapInputHandler input = new MapInputHandler( "SELECT name FROM students WHERE id = :id", queryParameters); Map<String, Object> result = runner.query(input, new MapOutputHandler()); QueryRunnerService runner = MjdbcFactory.getQueryRunner(conn); BeanInputHandler<Student> input = null; Student student = new Student(); student.setId(2); // :id is IN parameter and :name and :address are OUT parameters input = new BeanInputHandler<Student>("{call TEST_NAMED(:id, :name, :address)}", student); // result would be filled student object searched by ID = 2. All values would come from OUT param. Student result = runner.call(input); Mapinput example Beaninput example
  • 14. What’s next ? ◦ Visit http://www.midao.org/ ◦ Browse Midao JDBC code on GitHub. ◦ Browse Midao JDBC JavaDoc. ◦ Read getting started guide www.midao.org/mjdbc-getting-started.html ◦ Follow us on Freecode midao.
  • 15. Feedback, suggestions and questions ◦ stackoverflow.com still is the best place to start asking questions. ◦ Java Ranch (JDBC forum) is monitored for questions related to Midao JDBC. ◦ Mailing lists can be used: questions@midao.org ◦ midao.org have feedback section(below) where you can provide one. ◦ And if everything else fails - you can always contact me directly: pryzach@gmail.com.
  • 16. Wow, you are still reading ? Hope this library would be useful for you. THANK YOU