1 / 12

ODBC and JDBC

ODBC and JDBC. What are they libraries of function calls that support SQL statements Why do we need them Provide a way for an application to communicate with a database Why are they good interoperability. ODBC (Open Database Connectivity). Application. ODBC interface. Driver Manager.

tierra
Download Presentation

ODBC and JDBC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ODBC and JDBC • What are they • libraries of function calls that support SQL statements • Why do we need them • Provide a way for an application to communicate with a database • Why are they good • interoperability

  2. ODBC(Open Database Connectivity) Application ODBC interface Driver Manager Driver A Driver C Driver B DS C DS A DS B

  3. Adding an ODBC source • Purpose: register a data source • How-to (Windows 2000) • Start->Settings->Control Panel-> Administrative Tools->Data Sources(ODBC) NB: You need to register a new SQL server before you create the DSN

  4. Further steps…. • Select the System DSN tab • Click add and choose SQL server (usually the bottom driver listed). Click Finish.

  5. Further steps…. • Chose identification entered by the user. Note: this is not the default option, so pay attention • Enter the ID and password I gave you • Agree with everything else in the wizard • Test the data source and if your test succeeds, hit OK

  6. JDBC(Java Database Connectivity) • What is it: • Java classes that allow an app to communicate with a database • Three types of JDBC drivers: • Proprietary • Bridge Drivers (e.g. JDBC-ODBC) • JDBC-Net

  7. How does it work JDBC-ODBC bridge ODBC driver So, how does it work? You need to load the bridge driver and get a connection from the driver manager

  8. Confusing? Let’s look at some code import java.sql.*; Class FirstTry{ public static void main(String[] args){ try{ String url=“jdbc:odbc:myDSN”; /*load the driver from Sun.Even if you don’t understand this, this line is always the same*/ Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); //get a connection Connection con=DriverManager.getConnection(url,”userID”,”password”); }catch….

  9. How does it fit together • Note the DSN in the database url—it is the ODBC DSN • JDBC is just a way for Java applications to do what ASP does with ODBC.

  10. What next • Well, just have fun. Check out Sun’s API for the sql package http://java.sun.com/j2se/1.3/docs/api/index.html • See Sun’s tutorial on JDBC http://java.sun.com/tutorial

  11. The Front End • Web pages: static/dynamic • Techniques for creating dynamic content : • CGI (Perl), ASP, JSP • Requests, Responses and Headers • HTTP: simple, stateless. Client(I.e.browser) requests, web server responds • Requests can be of several types(methods): usually GET and POST

  12. ADO • Set of objects to modify and access data through OLE DB interface: • Connection, Command,Recordset,Error • Application uses ADO which talks to OLE DB provider for ODBC, which loads the right ODBC driver. Note: providers represent diverse sources of data, pick the right one

More Related