# WrapperImpl.jcs Sample

This topic inludes the source code for the WrapperImpl.jcs Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebApp/controls/database_iterator/dbcontrol_wrapper/

## Sample Source Code

`001 package controls.database_iterator.dbcontrol_wrapper; 002 003 import com.bea.control.*; 004 import java.io.Serializable; 005 import java.sql.ResultSet; 006 import java.sql.SQLException; 007 import java.util.ArrayList; 008 import java.util.Iterator; 009 import java.util.Vector; 010 import javax.sql.RowSet; 011 /** 012 * @editor-info:code-gen control-interface="true" 013 */ 014 public class WrapperImpl implements Wrapper, ControlSource 015 { 016 public static class User implements Serializable 017 { 018 public String username; 019 public String password; 020 021 public User() 022 { 023 } 024 025 public User( String username, String password ) 026 { 027 this.username = username; 028 this.password = password; 029 } 030 } 031 032 /** 033 * @common:control 034 */ 035 private controls.database_iterator.dbcontrol_wrapper.impl.UsersDBControl usersDBControl; 036 037 038 static final long serialVersionUID = 1L; 039 040 /** 041 * @common:operation 042 */ 043 public void createUsersTable() throws java.sql.SQLException 044 { 045 usersDBControl.createUsersTable(); 046 } 047 048 /** 049 * @common:operation 050 */ 051 public int deleteUser(java.lang.String username) 052 { 053 return usersDBControl.deleteUser(username); 054 } 055 056 /** 057 * @common:operation 058 */ 059 public ArrayList getAllUsers() throws SQLException 060 { 061 Iterator it = usersDBControl.getAllUsers(); 062 ArrayList al = new ArrayList(); 063 while(it.hasNext()) 064 { 065 User user = (User)it.next(); 066 al.add( user ); 067 } 068 return al; 069 } 070 071 /** 072 * @common:operation 073 */ 074 public int insertUser(java.lang.String username, java.lang.String password) 075 { 076 return usersDBControl.insertUser(username,password); 077 } 078 079 /** 080 * @common:operation 081 */ 082 public ArrayList lookupUser(java.lang.String username) throws SQLException 083 { 084 Iterator it = usersDBControl.getAllUsers(); 085 ArrayList al = new ArrayList(); 086 while(it.hasNext()) 087 { 088 User user = (User)it.next(); 089 al.add( user ); 090 } 091 return al; 092 } 093 094 /** 095 * @common:operation 096 */ 097 public int updateUser(java.lang.String username, java.lang.String password) 098 { 099 return usersDBControl.updateUser(username,password); 100 } 101 102 /** 103 * @common:operation 104 */ 105 public void acceptChanges(javax.sql.RowSet r) throws java.sql.SQLException, weblogic.jdbc.rowset.OptimisticConflictException 106 { 107 usersDBControl.acceptChanges(r); 108 } 109 }`