An Introduction to Network Programming with Java by Jan Graba

An Introduction to Network Programming with Java by Jan Graba

Author:Jan Graba
Language: eng
Format: epub, pdf
Publisher: Springer London, London


7.2 SQL and Versions of JDBC

The standard means of accessing a relational database is to use SQL (Structured Query Language). [Readers unfamiliar with SQL are advised to read the appendix on this subject before proceeding further with this chapter.] This is reflected in the fact that the package comprising the core JDBC API is called java.sql.

The original JDBC that was released with JDK 1.1 was JDBC 1.0, which comprised package java.sql. Using this API, it is possible to access data not only from relational databases, but also from spreadsheets and flat files—i.e., from just about any data source. With JDBC 2.0, which appeared in J2SE 1.4, extra functionality was introduced with the additional package javax.sql. Probably the most notable feature of this version was the introduction of the DataSource interface, which now provides the preferred method of making a connection to a database, This is due to the fact that a DataSource object has properties that can be modified. Thus, for example, if the data source is moved to a different server, the property for the server can be changed without requiring the code accessing the data source to be changed. In spite of the fact that the use of a DataSource object is the official preferred method of making connection to a database, the old method of making a connection, which involves the use of the DriverManager class, is still quite commonly used. Both of these techniques will be covered in this chapter.

The latest version of the JDBC API (at the time of writing) is JDBC 4.1, which is included with Java SE 7, and most drivers nowadays adhere to the JDBC 4 standard, which has been included in the Java installation since Java SE 6 (launched in December of 2006). However, users of earlier versions can expect their code to continue to work under Java SE 7, since one of the guiding design principles of each new version has been that of maintaining compatibility with existing applications and drivers.

In the examples that follow in the next two sections, a simple MS Access database will be used for purposes of illustration, which means that the inbuilt JDBC-ODBC bridge driver can be employed (even though, as noted at the end of 7.1, this may not be the best strategy in many commercial applications). Convenient though this may be, in view of the widespread use and availability of MS Access and the inclusion of the JDBC-ODBC bridge driver in the Java installation, it does introduce a couple of complications: (i) we have to create an ODBC Data Source and (ii) we need to use the 32-bit version of Java, even though there is now a 64-bit version. The reason for the latter is that, although a 64-bit version of MS Access does now exist, even Microsoft is recommending that the 32-bit version be installed for the time being: “For these reasons, we recommend running 32-bit Office 2010 even on 64-bit Windows operating systems for better compatibility…When the 64-bit ecosystem for Office is more mature, you’ll be able to easily migrate to 64-bit Office” [http:​/​/​blogs.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9802)
Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide by Eric McLeroy(6252)
The KCNA Book by Nigel Poulton(4292)
Microsoft Security, Compliance, and Identity Fundamentals Exam Ref SC-900 by Dwayne Natwick(3654)
Designing and Implementing Microsoft Azure Networking Solutions by David Okeyode(3558)
Microsoft Security Operations Analyst Exam Ref SC-200 Certification Guide by Trevor Stuart and Joe Anich(3513)
Microsoft Security Operations Analyst Exam Ref SC-200 Certification Guide by Trevor Stuart & Joe Anich(3432)
TCP IP by Todd Lammle(2993)
Microsoft Power BI Data Analyst Certification Guide by Ed Corcoran Orrin Edenfield(2925)
Unity Certified Programmer: Exam Guide by Philip Walker(2607)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2528)
Networking A Beginner's Guide by Bruce Hallberg(2216)
Microsoft Power Platform Solution Architect's Handbook by Hugo Herrera(2043)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1867)
CompTIA A+ Practice Tests Core 1 (220-1101) and Core 2 (220-1102) by Ian Neil and Mark Birch(1800)
MCSA Windows Server 2016 Study Guide: Exam 70-741 by William Panek(1669)
PHP 7 Zend Certification Study Guide by Andrew Beak(1651)
Healthcare Information Security and Privacy (All-In-One) by Sean Murphy(1553)
CompTIA A+ Certification Guide (220-901 and 220-902) by Matthew Bennett(1531)
RHCSA & RHCE Red Hat Enterprise Linux 7: Training and Exam Preparation Guide (EX200 and EX300), Third Edition by Asghar Ghori(1492)