IBM Websphere and Visualage for Java Database Integration with DB2, Oracle, and SQL Server

IBM Websphere and Visualage for Java Database Integration with DB2, Oracle, and SQL Server

IBM WebSphere and VisualAge for Java Database Integration with DB2, Oracle, and SQL Server Ueli Wahli, Tobias Himstedt, Sean Lee, Amir Razmara International Technical Support Organization www.redbooks.ibm.com SG24-5471-00 SG24-5471-00 International Technical Support Organization IBM WebSphere and VisualAge for Java Database Integration with DB2, Oracle, and SQL Server September 1999 Take Note! Before using this information and the product it supports, be sure to read the general information in Appendix B, “Special Notices” on page 269. First Edition (September 1999) This edition applies to • IBM WebSphere Application Server Version 2.0.2 • IBM WebSphere Studio Version 3.0 beta 2 • VisualAge for Java Version 2 with Rollup 2 and Enterprise Update • DB2 Universal Database Version 5.2 • Oracle Version 8 • Microsoft SQL Server Version 7 for use with the Windows NT Operating System, Service Pack 4. Sample Code on the Internet: The sample code for this redbook is available as 5471samp.zip file on the ITSO home page on the Internet: ftp://www.redbooks.ibm.com/redbooks/SG245471/ Download the sample code and read Chapter 3, “ITSO Sample Applications” on page 15. Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. QXXE Building 80-E2 650 Harry Road San Jose, California 95120-6099 When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright International Business Machines Corporation 1999. All rights reserved. Note to U.S Government Users – Documentation related to restricted rights – Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp. Contents Figures .................................................. ix Tables ..................................................xvii Preface ................................................. xix TheTeamThatWroteThisRedbook...............................xx CommentsWelcome............................................xxi Part 1. Introduction to IBM WebSphere and VisualAge for Java .1 Chapter 1. HTTP Server and WebSphere Application Server....3 Environment...................................................3 IBMHTTPServer...............................................4 Installation.................................................4 Configuration...............................................4 IBMWebSphereApplicationServer................................5 WebSphereInstallation.......................................5 WebSphereConfiguration.....................................6 WebSphereConfigurationforJDBC.............................7 StartingandStoppingWebSphere..............................8 Chapter 2. VisualAge for Java Enterprise Version 2 ............9 VisualAgeforJavaInstallation...................................10 VisualAgeforJavaConfigurationforJDBC.........................10 VisualAgeforJavaConfigurationforWebSphere....................10 WebSphereinVisualAgeforJava.................................11 DefaultDirectoriesforServletsandJSPfiles....................11 CompiledJSPs.............................................12 RunningServletsinVisualAgeforJava.........................12 Chapter 3. ITSO Sample Applications ........................15 SampleCode...............................................16 RepositoryExportFiles......................................17 © Copyright IBM Corp. 1999 iii Part 2. Database Setup and JDBC.............................19 Chapter 4. Relational Database Installation and Setup ........21 DB2UDBInstallation..........................................22 DB2UDBDatabaseSetup....................................22 DB2UDBTableCreation.....................................24 LoadingtheTableDataIntoDB2..............................26 DB2JDBCDrivers..........................................26 Oracle8Installation............................................27 OracleDatabaseSetup.......................................27 OracleTableCreation.......................................29 ImportingtheTableDataintoOracle...........................31 OracleJDBCDrivers........................................32 SQLServerInstallation.........................................33 SQL Server Database Setup ..................................33 SQLServerTableCreation...................................34 ImportingtheTableDataintoSQLServer.......................35 SQLServerJDBCDrivers....................................38 ODBCDataSourceSetupforJDBC............................38 Chapter 5. Java Database Connectivity.......................43 DB2UDBJDBCDrivers........................................44 DB2ApplicationDriver......................................44 DB2NetworkDriver.........................................45 OracleJDBCDrivers...........................................46 OracleThinClientDriver....................................46 OracleOCIDriver...........................................46 SQLServerJDBCDrivers.......................................47 ConfiguringVisualAgeforJavaforJDBC..........................48 ConfiguringWebSphereforJDBC.................................49 Part 3. Database Programming Examples .....................51 Chapter 6. JDBC Programming Examples ....................53 SimpleJDBCApplication........................................53 DB2UniversalDatabaseJDBCCodeExample......................56 OracleJDBCCodeExample......................................57 SQLServerJDBCCodeExample.................................58 RunningApplicationswithJDBC.................................60 TestingtheJDBCApplicationsinVisualAgeforJava..............60 RunningtheJDBCApplicationsintheOperatingSystem..........60 SimpleJDBCServlet...........................................61 iv IBM WebSphere and VisualAge for Java Database Integration with DB2, Oracle, and SQL Server TestingtheServletinVisualAgeforJava.......................63 RunningtheServletinWebSphere.............................63 Chapter 7. IBM Connection Manager .........................65 Configuration.................................................67 ConnectionPool............................................67 IBMConnectionManagerandPureJDBC..........................69 IBMConnectionManagerExamples...............................70 UsingtheIBMConnectionManager............................70 HTMLFileforAccessingtheServlets...........................71 RunningtheExample........................................72 DbaseConnMgrClass........................................73 DB2......................................................77 Oracle....................................................79 MicrosoftSQLServer........................................79 Chapter 8. Data Access Beans: VisualAge for Java ............81 LoadingtheDataAccessBeanFeature.............................82 DataAccessBeansandtheStandardSQLClasses...................82 DatabaseConnectionandjava.sql.Connection....................83 StatementTypes............................................85 ResultSetTypes............................................85 BuildingaServletusingDataAccessBeans.........................86 SampleDataAccessBeans...................................86 CreatingaServletVisuallyusingDataAccessBeans..............86 UsingtheConnectionManagerandDataAccessBeans...............98 ClassDefinition............................................98 Initialization...............................................99 FormParameterAccess.....................................100 FormProcessing...........................................101 EmployeeRetrieval.........................................102 EmployeeUpdate..........................................105 TestingtheServlet.........................................106 DeployingServletstoWebSphere................................107 Chapter 9. Persistence Builder: VisualAge for Java ..........109 WhatisPersistence?...........................................110 UsingDatabasestoProvidePersistence...........................110 PersistenceBuilderTools.......................................110 VendorSpecificConsiderations..................................111 PersistenceBuilderExample:EmployeesinDepartment.............112 ImporttheSchema.........................................112 GenerateandValidatetheObjectModel.......................115 InspecttheMap...........................................116 v GeneratetheJavaCodefortheObjectModel...................118 GeneratetheJavaCodefortheServiceClasses..................119 BuildtheServlet...........................................121 Changing the Datastore Database................................127 DeployingaServlettoWebSphere...............................128 Chapter 10. Enterprise JavaBeans ..........................131 EnterpriseJavaBeansfromaBird’s-EyePerspective................132 ACloserLook................................................132 DevelopingaContainerManagedPersistenceEntityBean...........133 SetupofVisualAgeforJava..................................134 CreateaDepartmentEnterpriseBean.........................135 AddthePropertiesandMethodstotheBean....................137 MaptheBeantotheSchema.................................140 GeneratetheCodeandTest..................................143 DeploytheEnterpriseBeantoWebSphere.........................149 AccesstheDepartmentBeanfromaServlet........................153 ClassDeclaration..........................................153 PerformTaskMethod.......................................154 Initialization..............................................154

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    310 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us