# UsersDBControl.jcx Sample

This topic inludes the source code for the UsersDBControl.jcx 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/impl/

## Sample Source Code

`01 package controls.database_iterator.dbcontrol_wrapper.impl; 02 03 import java.io.Serializable; 04 import java.sql.SQLException; 05 06 import com.bea.control.DatabaseControl; 07 import java.sql.ResultSet; 08 import java.util.Iterator; 09 import javax.sql.RowSet; 10 import controls.database_iterator.dbcontrol_wrapper.WrapperImpl.User; 11 12 /** 13 * @jc:connection data-source-jndi-name="cgSampleDataSource" 14 */ 15 public interface UsersDBControl extends com.bea.control.ControlExtension, DatabaseControl 16 { 17 /** 18 * @jc:sql statement="create table users (username VARCHAR(50), password VARCHAR(50))" 19 */ 20 public void createUsersTable() throws SQLException; 21 22 /** 23 * @jc:sql statement:: 24 * INSERT INTO USERS (username, password) 25 * VALUES ({username}, {password}) 26 * :: 27 */ 28 public int insertUser( String username, String password ); 29 30 /** 31 * @jc:sql iterator-element-type="controls.database_iterator.dbcontrol_wrapper.WrapperImpl.User" statement:: 32 * SELECT * FROM USERS WHERE USERNAME = {username} 33 * :: 34 */ 35 public Iterator lookupUser( String username ); 36 37 /** 38 * @jc:sql statement:: 39 * UPDATE USERS SET USERNAME = {username}, PASSWORD = {password} WHERE USERNAME = {username} 40 * :: 41 */ 42 public int updateUser( String username, String password ); 43 44 /** 45 * @jc:sql iterator-element-type="controls.database_iterator.dbcontrol_wrapper.WrapperImpl.User" statement:: 46 * SELECT * FROM USERS 47 * :: 48 */ 49 public Iterator getAllUsers(); 50 51 /** 52 * @jc:sql statement:: 53 * DELETE FROM USERS WHERE USERNAME = {username} 54 * :: 55 */ 56 public int deleteUser( String username ); 57 58 59 60 }`