SlideShare a Scribd company logo
1 of 40
Open Connectivity
BI, Integration, and Apps on Couchbase using ODBC and
JDBC
June, 2015
• Who I am
• Driver(s) Overview
• Relational Model
• Demos
• ODBC in-depth
• JDBC in-depth
• QA
Contents
• Worked in the data access space for eight years and counting
• ODBC, OLEDB, JDBC, ADO.NET, ODBO, XMLA
• Core developer for the current generation of Simba’s data
access technologies
• Collaborated at an Engineering Level with Simba ISV
Customers to design and implement data drivers that are
today being shipped world wide
Kyle at a glance
• Simba connects people to data.
• HQ’ed in Vancouver, BC.
• 100ish employees.
• Founded in 1991.
• In 1992, Simba co-authored the original ODBC standard with Microsoft.
• Simba produces the SimbaEngine® SDK and drivers for the leading data
sources on multiple platforms.
Simba Technologies at a glance
Simba Technologies at a glance
• Partnership to create read/write ODBC and JDBC drivers
• ODBC 3.80
• JDBC 4.0 and 4.1
• Allow easy access to data within Couchbase from your
favourite BI and ETL tools
Why is Simba here?
What is an
ODBC / JDBC
Driver?
N1QL mode to allow
easy and advanced
analytics
• Couchbase is NoSQL
• Dynamic schema, documents vary within a bucket
• ODBC and JDBC are SQL
• Expect a fixed schema, each column is one type
• Must map from dynamic schema data to fixed schema data
Schema(less)
• SQL
• Catalog, Schema, Table
• Couchbase
• Namespace, Keyspace
Schema => Namespace
Table => Keyspace (sort of)
Relational Mapping
http://www.prabathsl.com/2013/02/document-oriented-database_14.html
Sample JSON Document:
{“Id” : 1, “Name”: “Couchbase”, “Values” : [V1,V2]}
Simple Flattening
Id Name Values[0] Values[1]
1 Couchbase V1 V2
Sample JSON Document:
{“Id” : 1, “Name”: “Couchbase”, “Values” : [V1,V2]}
Parent
Child
Re-Normalization
Id Name
1 Couchbase
Id Index Value
1 0 V1
1 1 V2
Demos
• C API
• Versions: 2.x, 3.0, 3.52, 3.80, etc…
• Non-Windows platforms are ODBC 3.52
• Driver Managers
• Windows, iODBC, unixODBC, etc…
• All functions have return codes
• SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, etc…
ODBC Technicals
• SQLHENV, SQLHDBC, SQLHSTMT, SQLHDESC
• Relationship is one-to-many
ODBC: Handles
• Allocate with SQLAllocHandle, free with SQLFreeHandle
• Ensure you set the version of ODBC in use
SQLSetEnvAttr(
hEnv,
SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC3_80,
SQL_IS_INTEGER)
ODBC: Environment
• Allocate with SQLAllocHandle, created from SQLHENV
• Maintains the actual connection to Couchbase
• Create child statement objects to do work
• Disconnect with SQLDisconnect, free with SQLFreeHandle
ODBC: Connection
Open a connection using SQLDriverConnect
SQLDriverConnect(
hDbc,
windowHandle,
connStr, SQL_NTS, connStrLen
&outStrLen,
SQL_DRIVER_COMPLETE)
Last parameter allows driver to prompt for information if
connStr doesn’t contain all necessary information.
ODBC: Connection
• Specify a Driver or DSN
• Driver: Must specify all options in connection string
• DSN: Can specify options in connection string
Example:
“DSN=Couchbase;UID=kylep;PWD=testPassword;”
ODBC: Connection String
• Allocate with SQLAllocHandle, created from SQLHSTMT
• Used for issuing queries, retrieving catalog metadata
• Free with SQLFreeHandle
ODBC: Statement
• Use SQLExecDirect for one-off queries
• Use SQLPrepare and SQLExecute for repeated queries
SQLExecDirect(hStmt, “<query>”, SQL_NTS)
or
SQLPrepare(hStmt, “<query>”, SQL_NTS)
SQLExecute(hStmt)
ODBC: Querying
• After execution, there is a cursor on the results, positioned
before the first row
• Use SQLFetch to move the cursor
• SQLGetData can be used to fetch cell by cell
• SQLBindCol can also be used, much more efficient
ODBC: Results
• Reuse connections so driver caches are effective
• Use SQLBindCol over SQLGetData
• Use array fetches with SQLBindCol
• Use SQLPrepare once, SQLExecute multiple times with parameters for
loading data
• Use parameter arrays when binding parameters with SQLBindParameter
• Bind types to match reported parameter or column types
ODBC: Performance Tips
SQLGetData vs. SQLBindCol
10 million rows, 3 columns of wide char, integer, decimal values
ODBC: Performance Tips
Method Time (s)
SQLGetData 141.428
SQLBindCol 6.102
SQLBindCol (array[100]) 2.747
• Is the Java version of ODBC
• Versions: 3.0, 4.0, 4.1, etc…
• JDBC version is tied to Java version
• Simba will supply JDBC 4.0 and 4.1 versions
• There is a driver manager, but role is very limited
• Errors are reported via exceptions, warnings via
getWarnings()
JDBC Technicals
• Relationship is again one-to-many
JDBC: Object Hierarchy
• Never used directly by your code
• Must be loaded by referencing using Class.forName()
• FQCNs
• com.simba.couchbase.jdbc4.Driver
• com.simba.couchbase.jdbc41.Driver
• URL
• “jdbc:couchbase://<host>:<port>/<schema>;UseN1QLMode=0/1”
JDBC: Driver
• Example
String url = “jdbc:couchbase://localhost:8093/default;”
Class.forName(“com.simba.couchbase.jdbc4.Driver”);
Connection con = DriverManager.getConnection(url);
• With JDBC 4.0 and later, Class.forName() can be omitted
JDBC: Driver
• Used directly by your code
• FQCNs
• com.simba.couchbase.jdbc4.DataSource
• com.simba.couchbase.jdbc41.DataSource
• Can be used to programmatically set connection properties by
using functions instead of a connection string
• Allows use of advanced features such as PooledConnection
• Used less often than Driver
JDBC: DataSource
• Can create child statement objects for queries
• Can create DatabaseMetaData objects for metadata via
getMetaData()
• Common pitfalls
• Not closing connections; use a finally block to ensure it is closed
• Not checking warnings, ever; call getWarnings() regularly
• Creating a new connection for every operation; reuse connections where
possible
JDBC: Connection
• DatabaseMetaData
• Created by Connection objects
• Actually only one object per connection, cached and reused
• Provides access to catalog metadata
• getCatalogs(), getTables(), getColumns(), etc…
• Provides access to database metadata
• getDatabaseProductVersion(), getIdentifierQuoteString(), etc…
JDBC: Database MetaData
• Created by Connection objects
• Three different types
• Statement – for one-off querying
• PreparedStatement – for queries with parameters
• CallableStatement – for stored procedures with output parameters*
• Statement objects will eventually dispose of themselves once
out of scope, but best practice is to close() them when done
JDBC: Statement Objects
• Cannot use parameters
• Use execute(), executeQuery(), or executeUpdate() to
execute SQL or N1QL queries
JDBC: Statement
execute() Example
Statement stmt = conn.createStatement();
try {
if (stmt.execute(“select * from beer-sample”)) {
ResultSet rs = stmt.getResultSet();
rs.close();
}
}
finally {
stmt.close();
}
JDBC: Statement
• For use with parameters
• Can get metadata about results before execution with
getResultSetMetaData()
• Can get metadata about parameters using
getParameterMetaData()
• Use set*() functions to provide parameter values
JDBC: PreparedStatement
• When loading data, use batches
• Set all required parameters for one execution
• Call addBatch() to add the current set of parameters
• Call executeBatch() to execute all added batches at once
• Set parameters as reported types to avoid conversion overhead
in the driver
• Reuse the statement for multiple executions
JDBC: PreparedStatement
• Represents query results or catalog metadata
• Describe the result set using getMetaData()
• Move through result using next()
• Can use isAfterLast(), isFirst(), isLast(), etc. to check cursor position.
• Retrieve cell values using get*() methods
• The driver supports all conversions between types listed by the JDBC spec
• Try to retrieve as requested type to avoid conversion overhead
• Remember to check wasNull() after calling get*() method
JDBC: ResultSet
ResultSet Example
ResultSet rs = stmt.executeQuery(“<query>”);
try {
int numColumns = rs.getMetaData().getColumnCount();
while (rs.next()) {
for (int i = 0; i < numColumns; ++i) {
System.out.println(rs.getString(i));
}
}
}
finally {
rs.close();
}
JDBC: ResultSet
Q & A
simba.com

More Related Content

What's hot

Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013Roger Barnes
 
Java.sql package
Java.sql packageJava.sql package
Java.sql packagemyrajendra
 
Latest Advance Animated Ado.Net With JDBC
Latest Advance Animated Ado.Net With JDBC Latest Advance Animated Ado.Net With JDBC
Latest Advance Animated Ado.Net With JDBC Tarun Jain
 
Interface callable statement
Interface callable statementInterface callable statement
Interface callable statementmyrajendra
 
WebLogic on ODA - Oracle Open World 2013
WebLogic on ODA - Oracle Open World 2013WebLogic on ODA - Oracle Open World 2013
WebLogic on ODA - Oracle Open World 2013Michel Schildmeijer
 
Database and Java Database Connectivity
Database and Java Database ConnectivityDatabase and Java Database Connectivity
Database and Java Database ConnectivityGary Yeh
 
SQLcl the next generation of SQLPlus?
SQLcl the next generation of SQLPlus?SQLcl the next generation of SQLPlus?
SQLcl the next generation of SQLPlus?Zohar Elkayam
 
Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Zohar Elkayam
 
Change RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBChange RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBApaichon Punopas
 
JPA and Hibernate Performance Tips
JPA and Hibernate Performance TipsJPA and Hibernate Performance Tips
JPA and Hibernate Performance TipsVlad Mihalcea
 

What's hot (18)

Css
CssCss
Css
 
Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013
 
Jdbc
JdbcJdbc
Jdbc
 
java Jdbc
java Jdbc java Jdbc
java Jdbc
 
JDBC
JDBCJDBC
JDBC
 
Java.sql package
Java.sql packageJava.sql package
Java.sql package
 
Jdbc day-1
Jdbc day-1Jdbc day-1
Jdbc day-1
 
Latest Advance Animated Ado.Net With JDBC
Latest Advance Animated Ado.Net With JDBC Latest Advance Animated Ado.Net With JDBC
Latest Advance Animated Ado.Net With JDBC
 
Jdbc
JdbcJdbc
Jdbc
 
Interface callable statement
Interface callable statementInterface callable statement
Interface callable statement
 
WebLogic on ODA - Oracle Open World 2013
WebLogic on ODA - Oracle Open World 2013WebLogic on ODA - Oracle Open World 2013
WebLogic on ODA - Oracle Open World 2013
 
Database and Java Database Connectivity
Database and Java Database ConnectivityDatabase and Java Database Connectivity
Database and Java Database Connectivity
 
SQLcl the next generation of SQLPlus?
SQLcl the next generation of SQLPlus?SQLcl the next generation of SQLPlus?
SQLcl the next generation of SQLPlus?
 
Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?
 
Jdbc_ravi_2016
Jdbc_ravi_2016Jdbc_ravi_2016
Jdbc_ravi_2016
 
Change RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBChange RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDB
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
 
JPA and Hibernate Performance Tips
JPA and Hibernate Performance TipsJPA and Hibernate Performance Tips
JPA and Hibernate Performance Tips
 

Viewers also liked

Guney afrika cum_ulke_raporu_2013
Guney afrika cum_ulke_raporu_2013Guney afrika cum_ulke_raporu_2013
Guney afrika cum_ulke_raporu_2013UlkeRaporlari2013
 
Презентатция на тему «распечатывааем презентацию» Nikiforov Vladimir
Презентатция на тему «распечатывааем презентацию» Nikiforov VladimirПрезентатция на тему «распечатывааем презентацию» Nikiforov Vladimir
Презентатция на тему «распечатывааем презентацию» Nikiforov Vladimirecko_1972
 
CV Malcolm McCay 201607
CV Malcolm McCay 201607CV Malcolm McCay 201607
CV Malcolm McCay 201607Malcolm McCay
 
diccionario pictórico
diccionario pictóricodiccionario pictórico
diccionario pictóricoysy15
 
Foods to Eat & Avoid in Parkinson's in Hindi Iपार्किंसंस में क्या खाए और क्या...
Foods to Eat & Avoid in Parkinson's in Hindi Iपार्किंसंस में क्या खाए और क्या...Foods to Eat & Avoid in Parkinson's in Hindi Iपार्किंसंस में क्या खाए और क्या...
Foods to Eat & Avoid in Parkinson's in Hindi Iपार्किंसंस में क्या खाए और क्या...Herbal Daily
 
Foods to Eat in Constipation, Acidity & Gas
Foods to Eat in Constipation, Acidity & GasFoods to Eat in Constipation, Acidity & Gas
Foods to Eat in Constipation, Acidity & GasHerbal Daily
 

Viewers also liked (9)

Guney afrika cum_ulke_raporu_2013
Guney afrika cum_ulke_raporu_2013Guney afrika cum_ulke_raporu_2013
Guney afrika cum_ulke_raporu_2013
 
Lamperd_SWOT
Lamperd_SWOTLamperd_SWOT
Lamperd_SWOT
 
Презентатция на тему «распечатывааем презентацию» Nikiforov Vladimir
Презентатция на тему «распечатывааем презентацию» Nikiforov VladimirПрезентатция на тему «распечатывааем презентацию» Nikiforov Vladimir
Презентатция на тему «распечатывааем презентацию» Nikiforov Vladimir
 
CV Malcolm McCay 201607
CV Malcolm McCay 201607CV Malcolm McCay 201607
CV Malcolm McCay 201607
 
Interview by Reed (2014)
Interview by Reed (2014)Interview by Reed (2014)
Interview by Reed (2014)
 
diccionario pictórico
diccionario pictóricodiccionario pictórico
diccionario pictórico
 
Foods to Eat & Avoid in Parkinson's in Hindi Iपार्किंसंस में क्या खाए और क्या...
Foods to Eat & Avoid in Parkinson's in Hindi Iपार्किंसंस में क्या खाए और क्या...Foods to Eat & Avoid in Parkinson's in Hindi Iपार्किंसंस में क्या खाए और क्या...
Foods to Eat & Avoid in Parkinson's in Hindi Iपार्किंसंस में क्या खाए और क्या...
 
Foods to Eat in Constipation, Acidity & Gas
Foods to Eat in Constipation, Acidity & GasFoods to Eat in Constipation, Acidity & Gas
Foods to Eat in Constipation, Acidity & Gas
 
Almanya ulke raporu_2013
Almanya ulke raporu_2013Almanya ulke raporu_2013
Almanya ulke raporu_2013
 

Similar to BI, Integration, and Apps on Couchbase using Simba ODBC and JDBC

Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionMazenetsolution
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivityarikazukito
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptJDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptkingkolju
 
PROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part IPROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part ISivaSankari36
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Pooja Talreja
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivityVaishali Modi
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.pptNaveenKumar648465
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programmingrinky1234
 
JDBC Connectivity Model
JDBC Connectivity ModelJDBC Connectivity Model
JDBC Connectivity Modelkunj desai
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsTeamstudio
 

Similar to BI, Integration, and Apps on Couchbase using Simba ODBC and JDBC (20)

Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptJDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
 
PROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part IPROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part I
 
Jdbc
JdbcJdbc
Jdbc
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
 
Unit 5.pdf
Unit 5.pdfUnit 5.pdf
Unit 5.pdf
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programming
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC Connectivity Model
JDBC Connectivity ModelJDBC Connectivity Model
JDBC Connectivity Model
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational Controls
 
22jdbc
22jdbc22jdbc
22jdbc
 
Jdbc
JdbcJdbc
Jdbc
 

Recently uploaded

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 

Recently uploaded (20)

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 

BI, Integration, and Apps on Couchbase using Simba ODBC and JDBC

  • 1. Open Connectivity BI, Integration, and Apps on Couchbase using ODBC and JDBC June, 2015
  • 2. • Who I am • Driver(s) Overview • Relational Model • Demos • ODBC in-depth • JDBC in-depth • QA Contents
  • 3. • Worked in the data access space for eight years and counting • ODBC, OLEDB, JDBC, ADO.NET, ODBO, XMLA • Core developer for the current generation of Simba’s data access technologies • Collaborated at an Engineering Level with Simba ISV Customers to design and implement data drivers that are today being shipped world wide Kyle at a glance
  • 4. • Simba connects people to data. • HQ’ed in Vancouver, BC. • 100ish employees. • Founded in 1991. • In 1992, Simba co-authored the original ODBC standard with Microsoft. • Simba produces the SimbaEngine® SDK and drivers for the leading data sources on multiple platforms. Simba Technologies at a glance
  • 6.
  • 7. • Partnership to create read/write ODBC and JDBC drivers • ODBC 3.80 • JDBC 4.0 and 4.1 • Allow easy access to data within Couchbase from your favourite BI and ETL tools Why is Simba here?
  • 8. What is an ODBC / JDBC Driver? N1QL mode to allow easy and advanced analytics
  • 9. • Couchbase is NoSQL • Dynamic schema, documents vary within a bucket • ODBC and JDBC are SQL • Expect a fixed schema, each column is one type • Must map from dynamic schema data to fixed schema data Schema(less)
  • 10. • SQL • Catalog, Schema, Table • Couchbase • Namespace, Keyspace Schema => Namespace Table => Keyspace (sort of) Relational Mapping http://www.prabathsl.com/2013/02/document-oriented-database_14.html
  • 11. Sample JSON Document: {“Id” : 1, “Name”: “Couchbase”, “Values” : [V1,V2]} Simple Flattening Id Name Values[0] Values[1] 1 Couchbase V1 V2
  • 12. Sample JSON Document: {“Id” : 1, “Name”: “Couchbase”, “Values” : [V1,V2]} Parent Child Re-Normalization Id Name 1 Couchbase Id Index Value 1 0 V1 1 1 V2
  • 13. Demos
  • 14. • C API • Versions: 2.x, 3.0, 3.52, 3.80, etc… • Non-Windows platforms are ODBC 3.52 • Driver Managers • Windows, iODBC, unixODBC, etc… • All functions have return codes • SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, etc… ODBC Technicals
  • 15. • SQLHENV, SQLHDBC, SQLHSTMT, SQLHDESC • Relationship is one-to-many ODBC: Handles
  • 16. • Allocate with SQLAllocHandle, free with SQLFreeHandle • Ensure you set the version of ODBC in use SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3_80, SQL_IS_INTEGER) ODBC: Environment
  • 17. • Allocate with SQLAllocHandle, created from SQLHENV • Maintains the actual connection to Couchbase • Create child statement objects to do work • Disconnect with SQLDisconnect, free with SQLFreeHandle ODBC: Connection
  • 18. Open a connection using SQLDriverConnect SQLDriverConnect( hDbc, windowHandle, connStr, SQL_NTS, connStrLen &outStrLen, SQL_DRIVER_COMPLETE) Last parameter allows driver to prompt for information if connStr doesn’t contain all necessary information. ODBC: Connection
  • 19. • Specify a Driver or DSN • Driver: Must specify all options in connection string • DSN: Can specify options in connection string Example: “DSN=Couchbase;UID=kylep;PWD=testPassword;” ODBC: Connection String
  • 20. • Allocate with SQLAllocHandle, created from SQLHSTMT • Used for issuing queries, retrieving catalog metadata • Free with SQLFreeHandle ODBC: Statement
  • 21. • Use SQLExecDirect for one-off queries • Use SQLPrepare and SQLExecute for repeated queries SQLExecDirect(hStmt, “<query>”, SQL_NTS) or SQLPrepare(hStmt, “<query>”, SQL_NTS) SQLExecute(hStmt) ODBC: Querying
  • 22. • After execution, there is a cursor on the results, positioned before the first row • Use SQLFetch to move the cursor • SQLGetData can be used to fetch cell by cell • SQLBindCol can also be used, much more efficient ODBC: Results
  • 23. • Reuse connections so driver caches are effective • Use SQLBindCol over SQLGetData • Use array fetches with SQLBindCol • Use SQLPrepare once, SQLExecute multiple times with parameters for loading data • Use parameter arrays when binding parameters with SQLBindParameter • Bind types to match reported parameter or column types ODBC: Performance Tips
  • 24. SQLGetData vs. SQLBindCol 10 million rows, 3 columns of wide char, integer, decimal values ODBC: Performance Tips Method Time (s) SQLGetData 141.428 SQLBindCol 6.102 SQLBindCol (array[100]) 2.747
  • 25. • Is the Java version of ODBC • Versions: 3.0, 4.0, 4.1, etc… • JDBC version is tied to Java version • Simba will supply JDBC 4.0 and 4.1 versions • There is a driver manager, but role is very limited • Errors are reported via exceptions, warnings via getWarnings() JDBC Technicals
  • 26. • Relationship is again one-to-many JDBC: Object Hierarchy
  • 27. • Never used directly by your code • Must be loaded by referencing using Class.forName() • FQCNs • com.simba.couchbase.jdbc4.Driver • com.simba.couchbase.jdbc41.Driver • URL • “jdbc:couchbase://<host>:<port>/<schema>;UseN1QLMode=0/1” JDBC: Driver
  • 28. • Example String url = “jdbc:couchbase://localhost:8093/default;” Class.forName(“com.simba.couchbase.jdbc4.Driver”); Connection con = DriverManager.getConnection(url); • With JDBC 4.0 and later, Class.forName() can be omitted JDBC: Driver
  • 29. • Used directly by your code • FQCNs • com.simba.couchbase.jdbc4.DataSource • com.simba.couchbase.jdbc41.DataSource • Can be used to programmatically set connection properties by using functions instead of a connection string • Allows use of advanced features such as PooledConnection • Used less often than Driver JDBC: DataSource
  • 30. • Can create child statement objects for queries • Can create DatabaseMetaData objects for metadata via getMetaData() • Common pitfalls • Not closing connections; use a finally block to ensure it is closed • Not checking warnings, ever; call getWarnings() regularly • Creating a new connection for every operation; reuse connections where possible JDBC: Connection
  • 31. • DatabaseMetaData • Created by Connection objects • Actually only one object per connection, cached and reused • Provides access to catalog metadata • getCatalogs(), getTables(), getColumns(), etc… • Provides access to database metadata • getDatabaseProductVersion(), getIdentifierQuoteString(), etc… JDBC: Database MetaData
  • 32. • Created by Connection objects • Three different types • Statement – for one-off querying • PreparedStatement – for queries with parameters • CallableStatement – for stored procedures with output parameters* • Statement objects will eventually dispose of themselves once out of scope, but best practice is to close() them when done JDBC: Statement Objects
  • 33. • Cannot use parameters • Use execute(), executeQuery(), or executeUpdate() to execute SQL or N1QL queries JDBC: Statement
  • 34. execute() Example Statement stmt = conn.createStatement(); try { if (stmt.execute(“select * from beer-sample”)) { ResultSet rs = stmt.getResultSet(); rs.close(); } } finally { stmt.close(); } JDBC: Statement
  • 35. • For use with parameters • Can get metadata about results before execution with getResultSetMetaData() • Can get metadata about parameters using getParameterMetaData() • Use set*() functions to provide parameter values JDBC: PreparedStatement
  • 36. • When loading data, use batches • Set all required parameters for one execution • Call addBatch() to add the current set of parameters • Call executeBatch() to execute all added batches at once • Set parameters as reported types to avoid conversion overhead in the driver • Reuse the statement for multiple executions JDBC: PreparedStatement
  • 37. • Represents query results or catalog metadata • Describe the result set using getMetaData() • Move through result using next() • Can use isAfterLast(), isFirst(), isLast(), etc. to check cursor position. • Retrieve cell values using get*() methods • The driver supports all conversions between types listed by the JDBC spec • Try to retrieve as requested type to avoid conversion overhead • Remember to check wasNull() after calling get*() method JDBC: ResultSet
  • 38. ResultSet Example ResultSet rs = stmt.executeQuery(“<query>”); try { int numColumns = rs.getMetaData().getColumnCount(); while (rs.next()) { for (int i = 0; i < numColumns; ++i) { System.out.println(rs.getString(i)); } } } finally { rs.close(); } JDBC: ResultSet
  • 39. Q & A

Editor's Notes

  1. Note that Simba will provide and maintain the drivers, to obtain them you need to contact Simba.
  2. Talk about using REST to talk to Couchbase, sent N1QL queries straight to Couchbase. Showing ODBC diagram, JDBC is identical.
  3. ODBC: Excel/PowerBI JDBC: Lumira, potentially Pentaho