import javax.sql.*;
import java.sql.*;

public class DropDS
{
   public static void main(String[] args)
   {
       try
       {
           if(args.length != 1)
           {
               System.out.println("Usage:   DropDS <logical name>");
               System.out.println("Example: DropDS jdbc/FOO");
               System.exit(0);
           }

           java.util.Hashtable env = new java.util.Hashtable( 5 );
           env.put( "java.naming.factory.initial", "COM.ibm.db2.jndi.DB2InitialContextFactory" );
           javax.naming.Context ctx = new javax.naming.InitialContext( env );

           COM.ibm.db2.jdbc.DB2DataSource db2ds = (COM.ibm.db2.jdbc.DB2DataSource)ctx.lookup(args[0]);

           ctx.unbind(args[0]);

           System.out.println("DB2 JNDI Service:\nDropped DataSource for database " + db2ds.getDatabaseName() + " bound as " + args[0] + ".");

           ctx.close(); // writes data to .db2.jndi
       }
       catch(Exception ex)
       {
           ex.printStackTrace();
       }
   }
}