designing and developing ws b. ramamurthy. plans we will examine the resources available for...

27
Designing and Developing WS B. Ramamurthy

Upload: sophie-lamb

Post on 12-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Designing and Developing WS

B. Ramamurthy

Page 2: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Plans

• We will examine the resources available for development of JAX-WS based web services.

• We need an IDE, integrated development environment. It simplifies the development while providing tools for debugging and testing etc.

• Today we will work with netbeans (you are free to work with Eclipse or another IDE if you have invested time in learning an environment in your earlier classes.)

Page 3: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Get started

• www.netbeans.org• Version6.0 , 5.5.x are fine• I will work with version

5.5.1 tutorials• We will look at JAX-WS develop,

deploy and test cycle

Page 4: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Netbeans IDE

• Netbeans is a comprehensive IDE for enterprise/server side Java development.

• Lets examine the various regions of the Netbeans IDE.

Page 5: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Netbeans5.5

• Top line menu (File, Build, Run, Window are commonly used).

• Source editor area on the right.• Project files/folder explorer area on

the left.• Input/output area at the bottom.• Runtime (WindowRuntime)

Page 6: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Netbeans IDE

• Examine the various tools/tabs provided by the IDE.

• Setup and configure the server (it comes with a bundled Tomcat server).

• You will be deploying the webservice in this server.

Page 7: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Working with Oracle

• Use the Oracle DBMS on CSE machines. Information about this is available here.

• You can access csedb from your laptop as long you have enabled VPN and installed the appropriate driver and connected the data source. (and of course you have an internet connectivity).

• jdbc:oracle:thin:@oraserve.cse.buffalo.edu:1521:csedb• The driver is available here.

Page 8: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Standard Access to DB

APPLICATION

DRIVER

MGR

DBMSDriver 1

DBMSDriver 2

DBMSDriver 3

DBMS 1

DBMS 2

DBMS 3

DB

DB

DB

Page 9: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

ODBC Architecture

Application

Class1 Class2

Driver Manager

DriverType1 DriverType2 DriverType3

DataSource2DataSource1 DataSource3

ODBC

Page 10: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Open Database Connectivity (ODBC) Standard

• ODBC standard is an interface by which application programs can access and process SQL databases in a DBMS-independent manner. It contains:

• A Data Source that is the database, its associated DBMS, operating system and network platform

• A DBMS Driver that is supplied by the DBMS vendor or independent software companies

• A Driver Manager that is supplied by the vendor of the O/S platform where the application is running

Page 11: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

ODBC Interface

• It is a system independent interface to database environment that requires an ODBC driver to be provided for each database system from which you want to manipulate data.

• The database driver bridges the differences between your underlying system calls and the ODBC interface functionality.

Page 12: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

An Example

Application DriverManager

Access driver mySQL driver Oracle driver

odbc stan

dard API

Page 13: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Application in Java

Application inJava

DriverManager

Sybase driver mSQL driver Informix driver

odbc stan

dard API

jdbc API

Page 14: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Java Support for ODBC : JDBC

• When applications written in Java want to access data sources, they use classes and associated methods provided by Java DBC (JDBC) API.

• JDBC is specified an an “interface”. • An interface in Java can have many

“implementations”.• So it provides a convenient way to

realize many “drivers”

Page 15: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Java Support for SQL

• Java supports embedded SQL.• Also it provides an JDBC API as a

standard way to connect to common relational databases.

• Java.sql package and an extensive exception hierarchy.

Page 16: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Data Source

• Local relational database; Ex: Oracle

• Remote relational database on a server; Ex: InfoSource

• On-line information service; Ex: Dow Jones, Customer database

Page 17: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

SQL Statements

• SELECT {what} FROM {table name}• SELECT {what} FROM {table name}

WHERE {criteria}• SELECT {what} FROM {table name}

WHERE {criteria} ORDER BY {field} • Others• Queries are embedded as strings in a

Statement object.

Page 18: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

JDBC Components• Driver Manager: Loads database drivers, and manages

the connection between application & driver.• Driver: Translates API calls to operations for a specific

data source.• Connection: A session between an application and a

driver.• Statement: A SQL statement to perform a query or an

update operation.• Metadata: Information about the returned data, driver

and the database.• Result Set : Logical set of columns and rows returned

by executing a statement.

Page 19: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

JDBC Classes• Java supports DB facilities by providing

classes and interfaces for its components • DriverManager class• Connection interface (abstract class)• Statement interface (to be instantiated

with values from the actual SQL statement)

• ResultSet interface

Page 20: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Driver Manager Class

• Provides static, “factory” methods for creating objects implementing the connection interface.– Factory methods create objects on

demand

• When a connection is needed to a DB driver, DriverManager does it using it factory methods.

Page 21: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Connection interface

• Connection class represents a session with a specific data source.

• Connection object establishes connection to a data source, allocates statement objects, which define and execute SQL statements.

• Connection can also get info (metadata) about the data source.

Page 22: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Statement interface

• Statement interface is implemented by the connection object.

• Statement object provides the workspace for SQL query, executing it, and retrieving returned data.

• Types: Statement, PreparedStatement, CallableStatement

Page 23: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

ResultSet interface

• Results are returned in the form of an object implementing the ResultSet interface.

• You may extract individual columns, rows or cell from the ResultSet using the metadata.

Page 24: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

JDBC Application Architecture

Application

Connection

Driver Manager

Driver Driver Driver

DataSourceDataSource DataSource

Statement Result Set

Page 25: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

JDBC Programming Steps

• Import necessary packages; Ex: import java.sql.*;

• Include jdbc classes as a jar library.• Connect to the data source using

“identifying” string , a user name and password.

• Allocate Connection object, Statement object and ResultSet object

• Execute query using Statement object• Retrieve data from ResultSet object• Close Connection object.

Page 26: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Identifying Data Sources

• It is specified using URL format.• <scheme>: <sub_scheme>:<scheme-

specific-part>Example(for local source):

jdbc:odbc:tech_books• Alternatively, for remote connection,jdbc:odbc:thin:@oraserve.cse.buffalo.edu:1521cs

edb

Page 27: Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,

Connecting to a database on Netbeans

1. Add the driver jar file to the library for inclusion during compiling and building of the executable.

2. Add a new driver (jdbc:odbc) to the databases tab.

3. Open connection to the data source (in this case to an Oracle 9i instance)

4. On successful connection you can view the data source details (tables etc.).

5. You can programmatically access the content of the database from a Java program.

6. You can execute SQL command from the source editor window.