public void insert(Player player, League l, String division) throws NamingException
    {

        String INSERT_STMT="insert into registration(PID,LID,division) values (?,?,?)";
        DataSource ds = null;
        Connection connection = null;
        PreparedStatement insert_stmt = null;
        
         try {

            // Retrieve the DataSource from JNDI
            Context ctx = new InitialContext();
            if (ctx == null) {
                throw new RuntimeException("JNDI Context could not be found.");
            }
            ds = (DataSource) ctx.lookup("jdbc/myDatasource");
            
            if (ds == null) {
                throw new RuntimeException("DataSource could not be found.");
            }

            // Get a database connection
            connection = ds.getConnection("root","btes");

            // Create SQL INSERT statement
            
            insert_stmt = connection.prepareStatement(INSERT_STMT);
           
            insert_stmt.setInt(1,player.getPID());
            insert_stmt.setInt(2,l.getLID());
            insert_stmt.setString(3,division);
            
           int id = insert_stmt.executeUpdate();
            
            // Get the next Player object ID
            
    }catch (SQLException e) {
            throw new RuntimeException("A database error occured. "
                    + e.getMessage());

            // Handle any JNDI errors
        } catch (NamingException e) {
            throw new RuntimeException("A JNDI error occured. " + e.getMessage());

            // Clean up JDBC resources
        } finally {
            if (insert_stmt != null) {
                try {
                    insert_stmt.close();
                } catch (SQLException e) {
                }
            }
            if (connection != null) {
                try {
                    connection.close();
                } catch (Exception e) {
                    e.printStackTrace(System.err);
                }
            }
        }
    }