MDCFUG Is Java in Your Future? - PowerPoint PPT Presentation

About This Presentation
Title:

MDCFUG Is Java in Your Future?

Description:

MDCFUG Is Java in Your Future? Tyler Williams Principal Consultant _at_ dataTerrace twilliams_at_dataterrace.com Agenda The Java Learning Curve Why This is a Good Thing ... – PowerPoint PPT presentation

Number of Views:118
Avg rating:3.0/5.0
Slides: 22
Provided by: mdcfugComm
Category:

less

Transcript and Presenter's Notes

Title: MDCFUG Is Java in Your Future?


1
MDCFUGIs Java in Your Future?
  • Tyler Williams
  • Principal Consultant _at_ dataTerrace
  • twilliams_at_dataterrace.com

2
Agenda
  • The Java Learning Curve
  • Why This is a Good Thing
  • J2EE Breakdown
  • Sample Program
  • Q A

3
My Background
  • Consultant 2 1/2 years
  • Certified CF Developer
  • 4 years CF
  • 1 year Java
  • 6 years Oracle

4
Java Language Barriers
  • Non-Tag Based
  • Lower Level Than CF (more code)
  • Object Oriented
  • Strongly Typed Case Sensitive
  • Large Function Library
  • Powerful, Complex and Less Forgiving

5
Power of Perception
  • CF is Easy to Learn
  • Ease of Entry Brings Less Qualified Programmers
    to the Language
  • More Low Grade Programs are Written
  • CF Language Gets a Bad Rap

6
The Good Side of Barriers
  • Less Competition
  • Higher Rates
  • Protected Reputation

7
J2EE - Enterprise Java
  • Server-side Web Development
  • Standard Created by Sun
  • Many Competing Application Servers
  • App Servers Must Pass a Compatibility Test Suite
  • Vendors Add Extensions JSP Tag Libraries

8
J2EE Technologies
  • Lower Complexity
  • Java Server Pages (JSP)
  • Servlets
  • Higher Complexity
  • JDBC (Database Connectivity)
  • Enterprise Java Beans (EJB)
  • Java Messaging Service (JMS)

9
JSP Example
  • lt_at_ page info"Simple JSP Page example" gt
  • lt
  • String str "8th"
  • gt
  • lthtmlgt
  • ltheadgtlttitlegtSimple JSP Pagelt/titlegtlt/headgt
  • ltbody bgcolor"ffffff"gt
  • lth1gtWelcome to the lt str gt dimensionlt/h1gt
  • lt/bodygt
  • lt/htmlgt

10
Servlet Example
  • import java.io.
  • import servlet.
  • import servlet.http.
  • public class SimpleServlet extends HttpServlet
  • public void doGet (HttpServletRequest req,
    HttpServletResponse res)
  • throws ServletException, IOException
  • response.setContentType(text/html)
  • PrintWriter out response.getWriter()
  • out.println(lthtmlgtltheadgtlttitlegtSimple Servlet
    Examplelt/titlegtlt/headgt)
  • out.println(ltbody bgcolor"ffffff"gt)
  • String str "8th"
  • out.println(lth1gtWelcome to the str
    dimensionlt/h1gt)
  • out.println(lt/bodygtlt/htmlgt)

11
JDBC Example
  • Class.forName("oracle.jdbc.driver.OracleDriver")
  • String stUrl_ "jdbcoraclethin_at_host1521sid"
  • Connection connection_ DriverManager.getConnecti
    on(stUrl_, username",password")
  • PreparedStatement statement_ connection_.prepare
    Statement("SELECT fname, lname FROM EMPLOYEE")
  • ResultSet rs statement_.executeQuery()
    //execute query
  • while (rs.next())
  • String firstName rs.getString(1)
  • String lastName rs.getString(2)
  • strOut strOut firstName " " lastName
    "ltBRgt"
  • rs.close()
  • statement_.close()
  • connection_.close()

12
CF Comparison
  • ltcfquery name"main_select" datasource"MYDS"gt
  • SELECT fname, lname FROM EMPLOYEE
  • lt/cfquerygt
  • ltcfoutput query"main_select"gt
  • main_select.fname main_select.lname
  • lt/cfoutputgt

13
JDBC Metadata
  • getColumnCount - Returns the number of columns in
    this Result Set
  • getColumnName - Get the designated column's name
  • getColumnType - Retrieve the designated column's
    SQL type
  • isAutoIncrement - Indicates whether the
    designated column is automatically numbered, thus
    read-only

14
Model-View-Controller (MVC)
  • Model Data JDBC
  • View Presentation JSP
  • Controller Framework Servlet

15
MVC Flow
Client
1) Client submits a page request 2) Servlet
interprets request 3) Servlet retrieves
necessary info from JDBC 4) Servlet hands off
request and details to JSP for formatting and
presentation
Servlet
JDBC
JSP
16
Complete MVC Example
  • DimensionApp.java (Servlet)
  • DimensionVO.java (JDCB Class)
  • Display.jsp (JSP)

17
DimensionApp.java
  • import java.io.
  • import javax.servlet.
  • import javax.servlet.http.
  • import DimensionVO
  • public class DimensionApp extends HttpServlet
  • public void service (HttpServletRequest req,
    HttpServletResponse res)
  • throws ServletException, IOException
  • DimensionVO dvo new DimensionVO()
  • String mydim dvo.getDimension()
  • req.setAttribute("dimension", mydim)
  • RequestDispatcher rd
  • rd getServletContext().getRequestDispatche
    r("/jsp/Display.jsp")
  • rd.forward(req, res)

18
DimensionVO.java
  • import java.sql.
  • import java.util.
  • import java.io.
  • public class DimensionVO
  • String strOut
  • String stUrl_ "jdbcodbcmdcfug"
  • private Connection connection_ null
  • private PreparedStatement statement_ null
  • private ResultSet rs
  • public String getDimension ()
  • throws IOException
  • try
  • Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
  • Connection connection_ DriverManager.getConne
    ction(stUrl_, "Admin","")
  • statement_ connection_.prepareStatement("SELE
    CT dimension FROM DIMENSIONS")
  • rs statement_.executeQuery() //execute
    query
  • String mydim rs.getString(1)
  • strOut mydim
  • rs.close()

19
Display.jsp
  • lt_at_ page info"MVC Example" gt
  • ltString str (String)request.getAttribute("dimen
    sion")gt
  • lthtmlgt
  • ltheadgtlttitlegtMVC Examplelt/titlegtlt/headgt
  • ltbody bgcolor"ffffff"gt
  • lttablegt
  • lttrgt
  • lttd width150gt nbsp lt/tdgt
  • lttd width250 alignrightgt lth1gtWelcome to the lt
    str gt dimensionlt/h1gt lt/tdgt
  • lt/trgt
  • lt/tablegt
  • lt/bodygt
  • lt/htmlgt

20
Java Resources
  • Javas Home _at_ Sun
  • http//java.sun.com
  • Java Portals
  • http//www.theserverside.com
  • http//www.jguru.com/
  • Suns JDBC Tutorial
  • http//developer.java.sun.com/developer/onlineTra
    ining/Database/JDBC20Intro/

21
Java Bookshelf
  • The Java Language
  • Java in a Nutshell - Flanagan
  • Servlets/JSP
  • Java Servlet Programming - Hunter
  • Web Development With JavaServer Pages -
    Fields/Kolb
  • Core Servlets and JavaServer Pages - Hall
  • J2EE Application Architecture
  • Core J2EE Patterns - Alur
Write a Comment
User Comments (0)
About PowerShow.com