Professional Documents
Culture Documents
www.datadirect.com/products/data-connectivity
Visit refcardz.com to browse and download the entire DZone Refcardz collection
brought to you by...
#101 Get More Refcardz! Visit refcardz.com
CONTENTS INCLUDE:
The next generation of JDBC Drivers The most popular JDBC driver
was the ever popular Type 2 driver architecture to date is Type 4.
architecture. This architecture This architecture encapsulates
eliminated the need for the ODBC the entirety of the JDBC API
driver and instead directly called the implementation along with all
native client libraries shipped by the the logic for communicating
database vendors. This was quickly directly with the database in a
adopted by the DB vendors as it was single driver. This allows for easy
quick and inexpensive to implement deployment and streamlines the
since they could reuse the existing C/ development process by having
C++ based native libraries. This choice a single tier and a small driver all
still left Java developers worrying about in a 100% java package.
version and platform compatibility
issues (i.e. client version 6 is not
supported on HP-Itanium processors).
Some vendors still do their new development in
their native clients first. So, don’t assume that if Type 4 drivers have been the traditional favorite
Hot their website states that the JDBC driver supports Hot of Java application developers since its inception
Tip Kerberos that they mean their Type 4 driver – they Tip due to the clean design and ease of use; drop in the
may mean Type 2! driver jar and you’re up and running!
TYPE 5: NEW!
While not yet officially sanctioned by the JDBC Expert Performance Drivers specifically designed for multi-core, 64 bit,
Group, there is quite a bit of discussion surrounding the Architecture and virtualized environments.
new Type 5 driver proposal in the JDBC community. Getting Clean Spec Strict adherence to the JDBC standard, solving
down to the real functional differences, we see this list as the Implementation problems within the specification instead of using
requirements for Type 5 Drivers as follows: proprietary methods that promote vendor lock-in.
TINYINT byte
WHAT’S IN A DRIVER?
To illustrate what a JDBC driver does under the covers, take a look at this ‘anatomy of a JDBC driver’ diagram.
Debugging and Logging (2) Specify the location and password of the trustStore file
Well-written JDBC drivers offer ways to log the JDBC calls used for SSL server authentication. Set connect options
going through the driver for debugging purposes. As an or system properties (javax.net.ssl.trustStore and
example, to enable logging with some JDBC drivers, you javax.net.ssl.trustStorePassword).
simply set a connection option to turn on this spying capability: (3) If your database server is configured for SSL client
authentication, configure your keyStore information:
Class.forName(“com.ddtek.jdbc.sqlserver.SQLServerDriver”);
(a) Specify the location and password of the keyStore
Connection conn = DriverManager.getConnection file. Either set connect options or Java system
(“jdbc:datadirect:sqlserver://Server1:1433;User=TEST;Password=secret;
SpyAttributes=(log=(file)C:\\temp\\spy.log;linelimit=80;logTName=yes;t properties (javax.net.ssl.keyStore and javax.net.ssl.
imestamp=yes)”); keyStorePassword).
(b) If any key entry in the keyStore file is password-
Codeless Configuration (Hibernate and JPA)
protected, set the KeyPassword property to the
Codeless Configuration is the ability to change driver behavior
key password.
without having to change application code. Using a driver
under something like Hibernate or JPA means that the user Single Sign-on with Kerberos
cannot use proprietary extensions to the JDBC objects and Kerberos is an authentication protocol, which enables secure
should instead control and change driver behavior through proof of identity over a non-secure network. It is also used for
connection options. enabling single sign-on across multiple sites by delegating
credentials. To enable Kerberos:
Additionally, codeless configuration is the ability to monitor
and change JDBC driver behavior while the driver is in use. (1) Set the authenticationMethod connect option to
For example, using a tool like JConsole to connect to a driver Kerberos.
exported MBean and check the PreparedStatement pool stats (2) Modify the krb5.conf file to contain your Kerberos realm
and the KDC name for that realm. Alternatively, you WHERE clause SELECT (col1, col2, col3)
can set the java.security.krb5.realm and java.security.krb5. FROM table1 WHERE col1 = ‘foo’
server. Various types of failover exist for JDBC drivers so check UPDATE statement UPDATE table1
SET col1=val1, col2=val2,…
your driver documentation for support - the most common are WHERE col3=some_val
listed below:
DELETE statement DELETE FROM table1
WHERE col2=some_val
Connection In the case of the primary connection being unavailable, the
Failover connection will be established with the alternate server.
Escape Clauses
Extended Failover While the application is running, if a connection failover
occurs, the driver will reconnect to an alternate server and Escape Type Example
post a transaction failure to the application.
Call (a.k.a. stored procedure) {call statement}
{call getBookValues (?,?)}
Select Failover Same as extended, except instead of posting a transaction
failure, this level will reposition any ResultSets, so the
application will not know there was a failure at all. Function {fn functionCall}
SELECT {fn UCASE(Name)} FROM Employee
bulkLoad.load(“tmp.csv”);
// Alternatively, you can load from any ResultSet object into the
target table:
To get a listing of the functions supported by a given JDBC
Hot driver, use the getter methods on the DatabaseMetaData
bulkLoad.load(results);
Tip object: getStringFunctions(), getNumericFunctions(),
getTimeDateFunctions(), etc.
Hot For additional Bulk Load options, check the JDBC driver WildCard Description and Example
Tip documentation.
% (percent) Subsititute for zero or more characters.
SELECT * from emp where name like ‘Da%’
JDBC WITH HIBERNATE When choosing a driver to use with Hibernate, ensure your
Hot driver supports Codeless Configuration so that you can
Hibernate is one of the most popular Object Relational
Tip tune performance and change driver behavior without
having to modify the Hibernate code!
Mapping (ORM) frameworks used with JDBC. It is important
to note that even if you choose to use Hibernate instead of When writing Hibernate applications it is important to understand
writing pure JDBC, Hibernate must use a JDBC driver to get to the main files used to setup a Hibernate environment:
data! Therefore, Hibernate does not replace JDBC as the data Hibernate File Purpose
connectivity layer, it merely sits on top of it to interface with the Dialects (org.hibernate.dialect.*) Describes the SQL behavior of the JDBC
application: driver and database to which the application
is connecting.
Configuration File (hibernate. Contains the hibernate configuration
properties or hibernate.cfg.xml) settings, such as: JDBC driver and connection
information, dialect information, mapping
information, etc.
Mapping File The mapping file contains the mapping
between the application defined objects and
the relational data stored in the database.
Not all JDBC drivers are created equal! Look for a set of
JDBC drivers that can use a single dialect to connect to
Hot multiple versions of a database. There’s nothing worse than
Tip deploying your application with an Oracle 8 dialect and
discover that you need to redeploy with an
Oracle 10 dialect!
#82
CONTENTS INCLUDE:
■
■
About Cloud Computing
Usage Scenarios Getting Started with
Aldon Cloud#64Computing
■
Underlying Concepts
Cost
by...
■
Upcoming Refcardz
youTechnologies ®
■
Data
t toTier
brough Comply.
borate.
Platform Management and more...
■
Chan
ge. Colla By Daniel Rubio
tion:
dz. com
tegra ternvasll
ABOUT CLOUD COMPUTING one time events. TEN TS
INC ■
HTML LUD E:
us Ind Anti-PPaat
Basics
Automated growthHTM
ref car
nuorn
■
Valid
ation one time events, cloud ML
connected to what is now deemed the ‘cloud’. Having the capability to support
Apache Ant
Usef
Du
ti
■
ul M.
computing platforms alsoulfacilitate
#84
Open the gradual growth curves
n an
Page Source
o
■
s
Vis it
C
faced by web applications. Tools
Core
By Key ■
Elem
Patte
has changed substantially in recent years, especially with Structur
E: al Elem ents
INC LUD gration the entrance of service providers like Amazon, Google and Large scale growth scenarios involvingents
specialized
NTS and mor equipment
rdz !
HTML
CO NTE Microsoft. es e... away by
(e.g. load balancers and clusters) are all but abstracted
Continu at Every e chang
m
About ns to isolat
relying on a cloud computing platform’s technology.
Software i-patter
space
Hadoop
rdz .co
■
n
Re fca
e Work
Build
riptio
and Ant
Desc
These companies have a Privat
are in long deployed
trol repos
itory
webmana applications
ge HTM
L BAS
■
Build
re
Buil Repo
This Refcard active
will introduce are within
to you to cloud riente computing, with an
d units
RATION etc. Some platforms ram support large grapRDBMS deployments.
■
The src
dy Ha
softw
e ine loping and Java s written in hical on of
INTEG attribute
task-o it all
softwar emphasis onDeve es by
Mainl these
ines providers, so youComm can better understand
also rece JavaScri user interfac web develop and the rris
Vis it
Spring Security
codel chang desc
INUOU ding Task Level as the
e code
w ww.dzone.com
Label
Build
manu
al
d tool
depe deplo t need but as if
eve , a ) stalle the same nmen for stan overlap uen
(i.e. , inef Build t, use target enviro Amazon EC2: Industry standard it has
software and uagvirtualization ine. HTM , so <a>< tly are) nest
with terns problem ce pre-in whether dards
ated b></
ory. ns (i.e. Autom Redu ymen
has bec become e with a> is
via pat ticular d deploEAR) in each very little L
Subversion
reposit -patter s that Pay only cieswhat you consume
tagge or Amazon’s cloud
the curr you cho platform
computing isome
heavily based moron fine. b></ ed insid
lained ) and anti the par solution duce nden For each (e.g. WAR es t
ent stan ose to writ more e imp a></ e
not lega each othe
x” b> is
be exp text to “fi are al Depeapplication deployment
Web ge until t a
librarifew years agonmen
t enviro was similar that will softwaredard
industry standard and virtualization app
e HTM technology.
orta nt,
tterns to pro Minim packa nden
Mo re
CI can ticular con used can rity all depe all targe
s will L or XHT arent. Reg the HTM l, but r. Tags
etimes Anti-pa they
tend
es, but to most phone services:
y Integ alizeplans with le that
late fialloted resources, ts with an and XHT simplify all help ML, und ardless
L VS
XHTM <a><
in a par hes som
Centr
end,
Binar
pro cess. the practic enti ng incurred costgeme
nt
whether e a single
such
temp
resources on
were consumed
t enviro
nmen
orthenot. Virtualization MLaare your
othe
you prov
erst of L
b></
in muchallows physical piece of hardware to
ide be HTM
rily bad
Mana based
approac ed with the cial, but, implem anding
Creat targe es to actually r web
nden
cy rties are nt
of the a solid L has
into differe coding.resources
necessa pared to
chang
efi Depe prope itting utilized by multiple operating
function systems.simplerThis allows foundati job adm been arou
associat to be ben
er
Ge t
te builds commo
are not Fortuna
late Verifi e comm than on
n com Cloud computing asRun it’sremo
known etoday has changed this.
befor alitytohas irably, nd for
They they
etc.
Temp Build (e.g. bandwidth, n memory, CPU) be allocated exclusively to tely exp that som
lts whe
ually,
appear effects. Privat y, contin Every elem mov used
to be, HTML
ecte job e time
ed resu The various resourcesPerfo rm a
consumed by webperio applications
dicall (e.g. nt team
pag
individual operating entsinstances. ed to CSS
system Brow d. Earl
y HTM has expand . Whi
gration
opme because
adverse unintend d Builds sitory Build r to devel common e (HTML . ser ed far le it has don
ous Inte web dev manufacture L had very
Stage Repo
e bandwidth, memory, CPU) areIntegtallied
ration on a per-unit CI serve basis or XHT
produc tinu e Build rm an from
extensio .) All are more e its
e.com
DZone, Inc.
Cloud Computing
the
s on
expand
ISBN-13: 978-1-934238-71-4
140 Preston Executive Dr. ISBN-10: 1-934238-71-6
Suite 100
50795
Cary, NC 27513