Milestone 2 Hints - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Milestone 2 Hints

Description:

Milestone 2 Hints. MIE456 - Information Systems Infrastructure II. Vinod Muthusamy ... Write yourself (use reference solution from M1) Make it a remote object ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 11
Provided by: vinodmu
Category:
Tags: hints | milestone

less

Transcript and Presenter's Notes

Title: Milestone 2 Hints


1
Milestone 2 Hints
  • MIE456 - Information Systems Infrastructure II
  • Vinod Muthusamy
  • November 11, 2004

2
Component interactions
GUI
Server
Database
RMI
JDBC
3
Relevant classes
  • ApptRepositoryMySQL
  • Write JDBC calls
  • Pass object to ApptControllerServer
  • ApptControllerServer
  • Write yourself (use reference solution from M1)
  • Make it a remote object
  • Generate stub to be used by client
  • ApptControllerClient
  • Get reference to remote ApptControllerServer
    object
  • Pass object to CalGrid
  • CalGrid
  • Given

Database
Server
Client
ApptControllerServer ApptRepositoryMySQL
CalGrid ApptControllerClient
RMI
JDBC
4
Server ApptRepositoryMySQL
public class ApptRepositoryMySQL extends
ApptRepository public void RemoveUser(User
u) str DELETE FROM users WHERE userid
u.ID stmt.executeUpdate(str)

Database
Server
Client
ApptControllerServer ApptRepositoryMySQL
CalGrid ApptControllerClient
RMI
JDBC
5
Server ApptControllerServer
public class ApptControllerServer extends
UnicastRemoteObject implements ApptController
public ApptControllerServer() throws
RemoteException try System.setSecurityMan
ager(new RMISecurityManager()) ApptControllerS
erver server new ApptControllerServer (new
ApptRepositoryMySQL()) Naming.rebind(APPTSERV
ER" , server) catch ()
Database
Server
Client
ApptControllerServer ApptRepositoryMySQL
CalGrid ApptControllerClient
RMI
JDBC
6
Client ApptControllerClient
public class ApptControllerClient public static
void main(String args) System.setSecurityMa
nager(new RMISecurityManager()) try
ApptControllerServer server (ApptController
Server )Naming.lookup(url) CalGrid grid new
CalGrid(server) catch ()
Database
Server
Client
ApptControllerServer ApptRepositoryMySQL
CalGrid ApptControllerClient
RMI
JDBC
7
Suggested steps
  • RMI connection between client/server
  • Write ApptControllerServer
  • Most of the code is given
  • Make it remotable
  • Register server object with RMI registry
  • Use ApptMemoryBased as the database for now
  • ApptControllerServer server new
    ApptControllerServer (new ApptMemoryBased())
  • Generate server stub/skeleton
  • Write ApptControllerClient
  • Get reference to remote server object
  • Pass object to CalGrid

8
Suggested steps (2)
  • JDBC database calls
  • Write ApptRepositoryMySQL
  • Write implementation for functions in
    ApptRepository interface
  • Test your SQL statements first in MySQL Query
    Browser
  • Now use ApptRepositorMySQL as the database
  • ApptControllerServer server new
    ApptControllerServer (new ApptRepositoryMySQL())

9
JDBC prepared statements
  • Allows precompilation of SQL statements
  • Simple interface to set SQL parameters

10
JDBC prepared statements (2)
DELETE FROM users WHERE userid bob
Without prepared statement
public void RemoveUser(User u) Statement stmt
conn.createStatement() str DELETE FROM
users WHERE userid u.ID
stmt.executeUpdate(str)
With prepared statement
public void RemoveUser(User u) str DELETE
FROM users WHERE userid ? PreparedStatement
stmt conn.prepareStatement(str) stmt.setString(1
, u.ID) stmt.executeUpdate()
Write a Comment
User Comments (0)
About PowerShow.com