Oracle Programming Database Management Systems 1 architecture v

Oracle Programming Database Management Systems 1

architecture v Database Management Systems 2

JDBC (Java Database Connectivity ) JDBC enables programmers to use SQL queries from within java programs to access databases. v JDBC provides transparent access to relational databases from different vendors. v Database Management Systems 3

JDBC Database Management Systems 4

JDBC steps v v Create the database in your dbms Register the database as a data source Import java. sql. * at the beginning of your java file. Connect to a JDBC source – Connection con = Driver. Manager. get. Connection(“jdbc: oracle: thin: @cciora 02. uncc. edu: 1521: class”, ”user”, ”passwd”) v Create an SQL statement – Statement stmt = con. create. Statement(); – stmt. execute. Update("INSERT INTO sailor VALUES(22, 'dustin', 7, 45. 0)"); Database Management Systems 5

JDBC Step v Execute the statement – Result. Set rs = stmt. execute. Query(“Select * from …”) v Parse the result – rs. next(), rs. get. Float – Result. Set. Meta. Data contains the information about column v Close the statement and connection – stmt. close() – con. close Database Management Systems 6

Useful resources JDBC tutorial http: //java. sun. com/docs/books/tutorial/jdbc/in dex. html v UNCC COIT https: //cci-wiki 01. uncc. edu/servlets v v Sample. JDBC. java on the class webpage Database Management Systems 7

Java Servlets v v Web servers understand requests for pages in http and return their response in HTML format Static html vs. dynamic html – – v The webpage is based on data submitted by the user The data changes frequently (a weather-report) Web pages uses information from a database(stock) Maintain separate data about each client for personalization purposes(cookies). Java servlets are programs that extend the functionality of a web server and useful for building dynamic web pages on the fly. Database Management Systems 8

Java Servlet Advantage Works as a lightweight thread directly with the JVM rather than create a new process v Load once to memory and used by all threads v Share data among each other v Database Management Systems 9

How to run servlets Your machine, Java servlet development kit(JSDK) v COIT v – consult the webpage https: //cci-wiki 01. uncc. edu/servlets Database Management Systems 10

Examples v Hello. World – http: //coit-servlet 02. uncc. edu: 8080/wwang 22/Hello. World – Hello. World. java on the class webpage v More examples – DBServlet – http: //coit-servlet 02. uncc. edu: 8080/wwang 22/DBServlet. html – DBServlet. java on the class webpage Database Management Systems 11

JDBC and Servlet v Summary: v 1. Download PUTTY and Win. SCP 2. Download Hello. World, Sample. JDBC and DBServlet source code 3. Modify them and upload to your own space 4. Compile and run it v v v Database Management Systems 12

Some links v https: //cci-wiki 01. uncc. edu/servlets v JDBC-Servlet. doc on the class webpage Database Management Systems 13

Summary 3 -tire architecture v APIs such as JDBC and ODBC introduce a layer of abstraction between application and DBMS v Choose your language from JSP, Servlet, ASP, VC++, VB. v Database Management Systems 14
- Slides: 14