Download presentation
Presentation is loading. Please wait.
Published byTerence Clark Modified over 9 years ago
1
Database Management Systems 1 Xintao Wu Oracle Programming Instructor: Xintao Wu
2
Database Management Systems 2 Xintao Wu architecture v
3
Database Management Systems 3 Xintao Wu JDBC (Java Database Connectivity ) v 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.
4
Database Management Systems 4 Xintao Wu JDBC
5
Database Management Systems 5 Xintao Wu JDBC steps v Create the database in your dbms v Register the database as a data source v Import java.sql.* at the beginning of your java file. v Connect to a JDBC source –Connection con = DriverManager.getConnection(“jdbc:oracle:thin:@cci- ora02.uncc.edu:1521:class”,”user”,”passwd”) v Create an SQL statement –Statement stmt = con.createStatement(); – stmt.executeUpdate("INSERT INTO sailor VALUES(22,'dustin',7,45.0)");
6
Database Management Systems 6 Xintao Wu JDBC Step v Execute the statement –ResultSet rs = stmt.executeQuery(“Select * from …”) v Parse the result – rs.next(), rs.getFloat –ResultSetMetaData contains the information about column v Close the statement and connection – stmt.close() – con.close
7
Database Management Systems 7 Xintao Wu Useful resources v JDBC tutorial http://java.sun.com/docs/books/tutorial/jd bc/index.html http://java.sun.com/docs/books/tutorial/jd bc/index.html v UNCC COIT https://cci-wiki01.uncc.edu/servlets v Example http://www.sis.uncc.edu/~xwu/WEB- INF/classes/SampleJDBC.java http://www.sis.uncc.edu/~xwu/WEB- INF/classes/SampleJDBC.java
8
Database Management Systems 8 Xintao Wu Java Servlets v Web servers understand requests for pages in http and return their response in HTML format v Static html vs. dynamic html –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). v Java servlets are programs that extend the functionality of a web server and useful for building dynamic web pages on the fly.
9
Database Management Systems 9 Xintao Wu Java Servlet Advantage v 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
10
Database Management Systems 10 Xintao Wu How to run servlets v Your machine, Java servlet development kit(JSDK) v COIT –consult the webpage https://cci-wiki01.uncc.edu/servlets –Consult TA
11
Database Management Systems 11 Xintao Wu Examples v HelloWorld –http://coit-servlet02.uncc.edu:8080/xwu/HelloWorldhttp://coit-servlet02.uncc.edu:8080/xwu/HelloWorld –http://www.sis.uncc.edu/~xwu/WEB- INF/classes/HelloWorld.javahttp://www.sis.uncc.edu/~xwu/WEB- INF/classes/HelloWorld.java v More examples –DBServlet –http://coit-servlet02.uncc.edu:8080/xwu/DBServlet.htmlhttp://coit-servlet02.uncc.edu:8080/xwu/DBServlet.html –http://www.sis.uncc.edu/~xwu/WEB- INF/classes/DBServlet.javahttp://www.sis.uncc.edu/~xwu/WEB- INF/classes/DBServlet.java
12
Database Management Systems 12 Xintao Wu JDBC and Servlet v Summary: v 1. Download PUTTY and WinSCP v 2. Download HelloWorld, SampleJDBC and DBServlet source code v 3. Modify them and upload to your own space v 4. Compile and run it
13
Database Management Systems 13 Xintao Wu Some links v https://cci-wiki01.uncc.edu/servlets https://cci-wiki01.uncc.edu/servlets v http://www.sis.uncc.edu/~xwu/5160/JDBC -Servlet.doc http://www.sis.uncc.edu/~xwu/5160/JDBC -Servlet.doc
14
Database Management Systems 14 Xintao Wu Summary v 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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.