Creating Data Access Services - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Creating Data Access Services

Description:

Compile DBAccess.java file by typing following at command prompt. javac DBAccess.java ... Compile DBAccessServiceClient.java by typing following at command prompt ... – PowerPoint PPT presentation

Number of Views:13
Avg rating:3.0/5.0
Slides: 15
Provided by: BenT54
Learn more at: http://www.geongrid.org
Category:

less

Transcript and Presenter's Notes

Title: Creating Data Access Services


1
Creating Data Access Services
  • Presented by
  • Ashraf Memon

2
Overview
  • Writing data access service classes in Java
  • Generating service
  • Deploying services with Apache Axis
  • Generating client files and testing them

3
Writing data access service classes in Java
  • Data Access Services in Java heavily depend on
    JDBC
  • JDBC stands for Java Database Connectivity and is
    a industry standard Java API from Sun for talking
    to any database - depending on availability of
    database driver.

4
Writing data access service classes in Java
5
Writing data access service classes in Java
  • Sample Data Access class contains 1 function,
    which reads coordinate data from summer_institute
    database and generates XML for it.
  • Method signature is
  • public String parse(int criteria)
  • Complete class code follows

6
Writing Data Acess service classes in Java
(contd)
  • import java.io.IOException
  • import java.sql.SQLException
  • import java.sql.Connection
  • import java.sql.DriverManager
  • import java.sql.Statement
  • import java.sql.ResultSet
  • public class DBAccess
  • public DBAccess()

7
Writing Data Acess service classes in Java
(contd)
  • public String parse(int criteria) throws
    IOException, SQLException,
  • ClassNotFoundException
  • String xml "lttablegt\r\n\t"
  • Class.forName("com.mysql.jdbc.Driver")
  • Connection connection DriverManager.getConne
    ction(
  • "jdbcmysql//geon07.sdsc.edu3306/summer_
    institute", "root", "")
  • Statement stmt connection.createStatement()

8
Writing Data Acess service classes in Java
(contd)
String sql "SELECT FROM earthquake WHERE
magnitude gt " Integer.toString(criteria)
ResultSet record stmt.executeQuery(sql)
while (record.next()) xml
"ltrecordgt\r\n\t\t" xml "ltlongt"
record.getString("longitude")
"lt/longt\r\n\t\t" xml "ltlatgt"
record.getString("latitude") "lt/latgt\r\n\t\t"
xml "ltmagnitudegt" record.getString("magn
itude") "lt/magnitudegt\r\n\t"
xml "lt/recordgt\r\n\t"

9
Writing Data Acess service classes in Java
(contd)
xml "\r\n" xml "lt/tablegt" return
xml

10
Generating Service
  • Download DBAccessService directory from
    ftp//dotnet.sdsc.edu/CSIG-WS/
  • Save directory to C\training\user\code
  • Compile DBAccess.java file by typing following at
    command prompt
  • javac DBAccess.java
  • Run program by typing following at command prompt
  • java DBAccess

11
Generating Service (contd)
  • Output should be
  • lttablegt
  • ltrecordgt
  • ltlongt143.002lt/longt
  • ltlatgt37.2850lt/latgt
  • ltmagnitudegt2.25000E-02lt/magnitudegt
  • lt/recordgt
  • lt/tablegt

12
Deploying services with Apache Axis
  • Copy generated class file to C\training\tools\tom
    cat\webapps\axis\WEB-INF\classes\
  • Open deployDBAccess.wsdd in Textpad (Explanation
    by instructor)
  • Close file.

13
Deploying services with Apache Axis(contd)
  • Set classpath by typing classpath at command
    prompt
  • Execute deployment descriptor by typing deploy
    deployDBAccess.wsdd at command prompt.
  • This deploys webservice on Axis SOAP Server.

14
Generating client files and testing them(contd)
  • Compile DBAccessServiceClient.java by typing
    following at command prompt
  • javac DBAccessServiceClient.java
  • Execute Client by typing following at command
    prompt
  • java DBAccessServiceClient
  • Output should be sinilar to execution of DBAccess
Write a Comment
User Comments (0)
About PowerShow.com